Integration notes¶
What to settle when linking the library into a driver: build, calling conventions, lifetime, trust, and protocol choices.
Build and link¶
- Toolchain: VS 2022 with matching WDK / SDK
- Link
wknetlib.lib; additional include directory points atinclude - Product code includes only
<wknet/Wknet.h>(or fine-grained public headers), neversrc/wknetlibinternals - Debug / Release treat warnings as errors
Calling conventions¶
- Sync HTTP / WebSocket / TLS / certificate paths run at
PASSIVE_LEVEL - Public handles come from Create and leave via Close / Release; failure paths may Release unconditionally (
nullptris fine) SendOptions/AsyncOptionsare heap objects too — matching Create / Release- Inspect
_Must_inspect_result_return values
Lifetime and unload¶
- Reuse one
Sessionfor same-host requests so the pool can hit Responselifetime is independent ofRequest/AsyncOp— release each- After async APIs, call
wknet::http::Destroy()on the unload path, then tear down WSK and other subsystems - WebSocket: do not race
Closewith new I/O on the same handle; a common pattern is single-threaded connect → send → receive → close wknet::websocket::ReceiveMessage.Datapoints at an internal buffer valid until the next receive / close
Trust and defaults¶
- Production uses
CertPolicy::Verifywith a caller-suppliedCertificateStore(anchors / pins) - Do not leave
NoVerifyin release configuration - HTTPS→HTTP redirects are refused by default; cross-origin redirects strip sensitive headers
- On stale connection failure, only
GET/HEAD/OPTIONSauto-retry once; POST and similar methods are never auto-replayed - Hard revocation: explicit
RequireRevocationCheckplus verifiable OCSP/CRL evidence
Diagnostics¶
- Product Trace defaults to
Off(Info when needed); do not log bodies, cookies, secrets, or full URL queries - Prefer component filters; avoid global Max in production
Protocol choices¶
- HTTP/3 defaults to
Auto; useDisabledwhen unwanted,Requiredfor prior knowledge - h2c, pipelining, 0-RTT, permessage-deflate and other default-off features stay off until explicitly enabled
- Support scope and limits: Capability matrix
Recipes: Cookbook. Semantics: Session & pool, Async model.