Skip to content

Commit 5b6e5e7

Browse files
authored
HTTP transport for call/publish (#1512)
- New `HttpTransport` (lib/runtime/transports/http.js): POST /{basePath}/capability/{call|publish}/{name}, dispatcher-code → HTTP-status mapping, 1 MiB body cap, optional verifyRequest hook. Re-exported from lib/runtime/index.{js,d.ts}. - Browser SDK (web/client.js, web/index.d.ts) now multi-transport: connect() / RosClient accept `string | { http, ws }` and pick the transport from the URL scheme. http:// derives a sibling ws:// URL and opens it lazily on first subscribe(). New _HttpLink uses fetch() and surfaces structured errors (network_error, invalid_response, http_<status>). - Tests: test/test-web-http.js (+423, 23 cases covering wire format, SDK, and defensive paths). test-web.js → test-web-ws.js. - CI: suppress two Node-internal LSan reports (ContextifyContext, ContextifyScript) triggered once we load web/client.js as ESM and call fetch() — singletons retained for process lifetime. - Drop unused WebSocketConnection export from transports/ws.js. Fix: #1510
1 parent 134e06b commit 5b6e5e7

9 files changed

Lines changed: 1200 additions & 55 deletions

File tree

lib/runtime/index.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,20 @@ export class WebSocketTransport extends TransportAdapter {
104104
path: string;
105105
}
106106

107+
export interface HttpTransportOptions {
108+
port?: number;
109+
host?: string;
110+
basePath?: string;
111+
verifyRequest?: (req: import('http').IncomingMessage) => boolean;
112+
}
113+
114+
export class HttpTransport extends TransportAdapter {
115+
constructor(options?: HttpTransportOptions);
116+
port: number;
117+
host: string;
118+
basePath: string;
119+
}
120+
107121
export interface CreateRuntimeOptions {
108122
node: Node;
109123
transport?: TransportAdapter;

lib/runtime/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const { Dispatcher } = require('./dispatcher.js');
1313
const { Connection } = require('./connection.js');
1414
const { TransportAdapter } = require('./transport_adapter.js');
1515
const { WebSocketTransport } = require('./transports/ws.js');
16+
const { HttpTransport } = require('./transports/http.js');
1617

1718
/**
1819
* The Web Runtime composes a capability registry, a dispatcher, and one or
@@ -134,4 +135,5 @@ module.exports = {
134135
Connection,
135136
TransportAdapter,
136137
WebSocketTransport,
138+
HttpTransport,
137139
};

0 commit comments

Comments
 (0)