Skip to content

Commit 50fdedf

Browse files
committed
Update examples and README
1 parent acd2227 commit 50fdedf

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/examples/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,10 @@ Or run the WebSocket client:
9999
npx tsx src/examples/ws-client.ts
100100
```
101101

102-
The HTTP example sends a bearer token through custom request headers. The WebSocket example passes the Node `ws` constructor so custom headers can be sent during the WebSocket handshake. Browser WebSocket clients can use `createWebSocketStream` too, but browsers do not allow custom WebSocket headers.
102+
The HTTP example sends a bearer token through custom request headers. `createHttpStream` includes cookies by default for the lifetime of one stream: it sends credentials on fetch requests, captures exposed `Set-Cookie` headers, merges them with caller-provided `Cookie` headers, and reuses them for connection SSE, session SSE, POST, and DELETE requests. Pass `cookies: "omit"` to disable this behavior for stateless transports.
103+
104+
The WebSocket server example uses `createNodeWebSocketUpgradeHandler`, which creates the ACP connection before the upgrade completes and adds `Acp-Connection-Id` to the `101 Switching Protocols` response. Frameworks that only expose an already-upgraded WebSocket socket cannot add that response header, so prefer an upgrade hook when building compliant servers.
105+
106+
The WebSocket client example passes the Node `ws` constructor so custom headers can be sent during the WebSocket handshake. Browser WebSocket clients can use `createWebSocketStream` too, but browsers do not allow custom WebSocket headers. Use cookies or URL-level authentication for browser WebSocket authentication instead of relying on custom handshake headers.
107+
108+
The included Node HTTP server is an HTTP/1.1 compatibility adapter. HTTP/2 deployment guidance is still tracked separately in the transport hardening plan.

src/examples/http-client.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ const stream = createHttpStream(serverUrl, {
3434
headers: {
3535
Authorization: "Bearer example-token",
3636
},
37-
// To use cookies, pass a cookie-aware fetch implementation here instead of relying on a built-in cookie jar.
38-
// fetch: cookieAwareFetch,
37+
// Cookies are included by default and scoped to this stream. Use `cookies: "omit"` for stateless requests.
3938
});
4039
const connection = new acp.ClientSideConnection(
4140
(_agent) => new HttpExampleClient(),

src/examples/http-server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const acpServer = new AcpServer({
7171
});
7272
const acpHttpHandler = createNodeHttpHandler(acpServer);
7373
const webSocketServer = new WebSocketServer({ noServer: true });
74+
// Use the ACP upgrade helper so the 101 response includes Acp-Connection-Id.
7475
const acpWebSocketUpgradeHandler = createNodeWebSocketUpgradeHandler(
7576
acpServer,
7677
webSocketServer,

0 commit comments

Comments
 (0)