Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
eachHttpClient((httpClient) => {
if (transportType === HttpTransportType.HttpStreaming && !httpClient.supportsStreaming) {
return;
}
describe(`over ${HttpTransportType[transportType]} with ${(httpClient.constructor as any).name}`, () => {
it("can send and receive messages", (done) => {
const message = "Hello World!";
// the url should be resolved relative to the document.location.host
// and the leading '/' should be automatically added to the url
const connection = new HttpConnection(ECHOENDPOINT_URL, {
...commonOptions,
httpClient,
transport: transportType,
});
connection.onreceive = (data: any) => {
if ((typeof data === "string" && data === message) ||
(data instanceof ArrayBuffer && new TextDecoder("utf-8").decode(data) === message)) {
export function getHttpTransportTypes(): HttpTransportType[] {
const transportTypes = [];
if (typeof window === "undefined") {
transportTypes.push(HttpTransportType.WebSockets);
transportTypes.push(HttpTransportType.ServerSentEvents);
} else {
if (typeof WebSocket !== "undefined") {
transportTypes.push(HttpTransportType.WebSockets);
}
if (typeof EventSource !== "undefined") {
transportTypes.push(HttpTransportType.ServerSentEvents);
}
}
transportTypes.push(HttpTransportType.HttpStreaming);
transportTypes.push(HttpTransportType.LongPolling);
return transportTypes;
}
getHttpClients().forEach((httpClient) => {
if (transport === HttpTransportType.HttpStreaming && !httpClient.supportsStreaming) {
return;
}
action(transport, protocol, httpClient);
});
});