Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BasedOnStyle: InheritParentConfig
# These arguments are header-name tokens, not arithmetic expressions.
WhitespaceSensitiveMacros:
- WEBCPP_ASIO_BACKEND_HEADER
- WEBCPP_BEAST_BACKEND_HEADER
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
* text=auto
*.sh text eol=lf

# Unified patches must retain the prefix on empty context lines.
*.patch whitespace=-blank-at-eol,-blank-at-eof

# Preserve the pinned, mechanically generated implementation's whitespace.
include/webcpp/beast/detail/backend/** -whitespace
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Read the superproject's [AGENTS.md](../../AGENTS.md) and
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.
WASIp2/P3 guest transport; `//tls` selects source-built OpenSSL explicitly.
P2 guest socket and TLS protocol tests pass; the full migrated application corpus
remains a separate validation gate. Do not infer corpus parity from core 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
Expand Down
6 changes: 2 additions & 4 deletions build.jam
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ 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 ;
Expand All @@ -17,6 +16,7 @@ feature.feature webcpp-beast-unsupported : error ignore : propagated ;

# Data interfaces do not require a socket reactor or guest TLS library.
alias beast : : : : <include>include <library>/webcpp/config//config
<library>/webcpp/asio//headers
<webcpp-beast-unsupported>error:<define>WEBCPP_BEAST_UNSUPPORTED_ERROR
<webcpp-beast-unsupported>ignore:<define>WEBCPP_BEAST_UNSUPPORTED_IGNORE ;

Expand All @@ -30,9 +30,7 @@ alias tls : : : : <library>sockets <library>/webcpp/asio//openssl ;
alias browser : : : : <library>beast <library>/webcpp/asio//asio ;

# Host HTTP bindings are independent of guest sockets and guest TLS.
alias wasi-http : : : : <library>beast <library>/webcpp/wasi//host-http
<toolset>clang-wasip2:<library>/webcpp/asio-wasip3//host-headers
<toolset>clang-wasip3:<library>/webcpp/asio-wasip3//headers ;
alias wasi-http : : : : <library>beast <library>/webcpp/wasi//host-http ;

# Supplied CLI streams use the portable WASI resource layer, not guest sockets.
alias wasi-streams : : : : <library>beast <library>/webcpp/wasi//wasi ;
352 changes: 240 additions & 112 deletions doc/application-matrix.adoc

Large diffs are not rendered by default.

51 changes: 44 additions & 7 deletions doc/beast.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
:attribute-missing: warn

`webcpp::beast` is a {cpp}20 compatibility facade for Boost.Beast applications.
Its purpose is to make those applications usable in WebAssembly through
Emscripten or WASIp2/P3, with explicit adaptations where the host has different
network facilities. JSPI and Asyncify are Emscripten suspension variants;
they are not WASI versions. Native upstream-equivalent types, including the
WebSocket stream, are aliases of the actual Boost.Beast types.
It preserves Boost.Beast's messages, buffers and parsers while selecting a
transport appropriate to the program's environment. Native and WASIp3 socket
transport appropriate to the program's environment. Native and WASIp2/P3 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
Expand Down Expand Up @@ -113,7 +118,7 @@ fails the test. Supplying a guest TCP acceptor is unnecessary for this backend.
|===
|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//sockets` |Native/WASIp2/P3 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.
Expand All @@ -130,10 +135,32 @@ 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.

[#beast-distribution]
=== Build without B2

Use `webcpp/beast/` headers and `webcpp::beast` names, together with the
corresponding `webcpp::asio` types. Native equivalents are actual Boost types.
Wasm selects the versioned protocol implementation shipped in the library;
the maintainer importer is not a consumer build step, and no replacement Boost
include tree is needed. Boost 1.92 remains an explicit dependency for other
Boost facilities used by these headers.

Socket and browser programs compile Asio's target-specific runtime source and
use matching thread, exception and suspension settings. Guest TLS adds the
explicit OpenSSL and CA provider. Host HTTP instead needs the bindings generated
from the selected WASI world. These are different dependency contracts, not
automatic substitutions based on an HTTP URL.

The superproject's `tools/test/fixtures/portable-network/CMakeLists.txt` builds
HTTP and WebSocket consumers from copied source distributions with explicit
toolchain and dependency inputs. It uses the same implementation as B2.
Application-matrix and measurement results identify their tested revision;
historical results do not validate this distribution migration.

[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-wasip2 testing.launcher=tools/boost/asio-wasip2/run.sh 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
----
Expand Down Expand Up @@ -179,11 +206,21 @@ 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
The WASI WebSocket allocator constructor accepts the portable constructor
syntax, but upstream Beast still controls its internal stream-state allocation.
Native uses the actual Boost stream and its original constructors.
Associated completion-handler allocators retain upstream semantics. Data containers
use their upstream allocator template parameters.

The shipped Wasm engine corrects an upstream `noexcept` on the internal variant
used by HTTP chunk serialization. With exceptions enabled, failure to allocate a
chunk header propagates `std::bad_alloc`; without exceptions, allocation failure
is not recoverable. Native retains the actual Boost 1.92 implementation, which
terminates on that particular allocation failure. Error-code overloads do not
turn allocation exceptions into protocol error codes. The browser regression
injects the failure through the public HTTP serializer and verifies both the
exception and the successful serialization controls.

`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
Expand All @@ -201,13 +238,13 @@ API or transport detail of the original program is available.
|===
|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
|Guest HTTP/WebSocket socket engine |Asio sockets |Asio pollable socket backend; see the dated application matrix |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
|Guest TLS, identity verification and shutdown |Source-built OpenSSL |Source-built OpenSSL |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
|Raw TCP HTTP/WebSocket listener |Available |Available with network grants |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
|===
Expand Down
2 changes: 2 additions & 0 deletions doc/changelog.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Changes to the unreleased Beast facade.
=== Unreleased

// tag::unreleased[]
* Fixed browser HTTP and WebSocket transfers with shared Wasm memory.
* Added current application coverage and shared Release parser measurements.
// end::unreleased[]

[#beast-changelog-0-1-0]
Expand Down
20 changes: 20 additions & 0 deletions doc/verification.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
[#beast-verification]
== Verification and reproduction

The <<application-profile-matrix>> contains the current application refresh for the
shipped implementation, including separate browser page/worker and single/multi
profiles. The dated contract-test record below remains historical evidence; it
must not be read as a fresh run of the unsubmitted migration or as performance
data.

The shared
link:{webcpp-libs}/cobalt/{webcpp-page}#cobalt-release-measurements[Release comparison]
also measures Beast HTTP response parsing inside matched Asio/Cobalt workloads.
That in-memory parser workload measures neither transport latency nor TLS
throughput. It must not be presented as a network performance comparison.

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,
Expand Down Expand Up @@ -75,6 +87,14 @@ 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.

The local closure regression on 2026-11-07 additionally exercises the public HTTP
serializer in real Chrome with JSPI and Asyncify. With exceptions enabled, a
forced chunk-header allocation failure must reach the caller as `std::bad_alloc`,
not abort. A fixed-length body and successful chunked serialization are controls.
The builds without exceptions exercise successful serialization only; they do
not claim recovery from exhausted memory. The native Boost 1.92 reproduction
retains the upstream termination behavior described in <<beast-explanation>>.

[#beast-reproduce]
=== Reproduce a suite

Expand Down
Loading
Loading