• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

microsoft / botbuilder-js / 14082188906

26 Mar 2025 11:29AM UTC coverage: 84.47% (-0.05%) from 84.524%
14082188906

push

github

web-flow
refactor: [#4759] Migrate off @azure/core-http (#4834)

* Migrate deprecated core-http to new libraries

* Fix ESLint

* Remove unused dependency

* Fix node_modules pathing

* Remove unused folder declaration

* Fix TypeScript modifying .js and .d.ts files

* Fix eslint

8260 of 10940 branches covered (75.5%)

Branch coverage included in aggregate %.

129 of 148 new or added lines in 22 files covered. (87.16%)

6 existing lines in 3 files now uncovered.

20572 of 23193 relevant lines covered (88.7%)

3968.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

63.16
/libraries/botbuilder/src/streaming/streamingHttpClient.ts
1
/**
2
 * @module botbuilder
3
 */
4
/**
5
 * Copyright (c) Microsoft Corporation. All rights reserved.
6
 * Licensed under the MIT License.
7
 */
8

9
import {
10
    WebResourceLike as WebResource,
11
    HttpOperationResponse,
12
    HttpClient,
13
} from 'botbuilder-stdlib/lib/azureCoreHttpCompat';
14
import { IStreamingTransportServer, StreamingRequest } from 'botframework-streaming';
1✔
15

16
/**
17
 * An implementation of `HttpClient` that adds compatibility with streaming connections.
18
 */
19
export class StreamingHttpClient implements HttpClient {
1✔
20
    private readonly server: IStreamingTransportServer;
21

22
    /**
23
     * Creates a new streaming Http client.
24
     *
25
     * @param server Transport server implementation to be used.
26
     */
27
    constructor(server: IStreamingTransportServer) {
28
        if (!server) {
6✔
29
            throw new Error('StreamingHttpClient: Expected server.');
1✔
30
        }
31
        this.server = server;
5✔
32
    }
33

34
    /**
35
     * This function hides the default sendRequest of the HttpClient, replacing it
36
     * with a version that takes the WebResource created by the BotFrameworkAdapter
37
     * and converting it to a form that can be sent over a streaming transport.
38
     *
39
     * @param httpRequest The outgoing request created by the BotframeworkAdapter.
40
     * @returns The streaming transport compatible response to send back to the client.
41
     */
42
    async sendRequest(httpRequest: WebResource): Promise<HttpOperationResponse> {
43
        if (!httpRequest) {
2✔
44
            throw new Error('StreamingHttpClient.sendRequest(): missing "httpRequest" parameter');
1✔
45
        }
46
        if (!this.server.isConnected) {
1✔
47
            throw new Error(
1✔
48
                'StreamingHttpClient.sendRequest(): Streaming connection is disconnected, and the request could not be sent.',
49
            );
50
        }
51

UNCOV
52
        const request = this.mapHttpRequestToProtocolRequest(httpRequest);
×
UNCOV
53
        request.path = request.path.substring(request.path.indexOf('/v3'));
×
UNCOV
54
        const res = await this.server.send(request);
×
55
        return {
×
56
            request: httpRequest,
57
            status: res.statusCode,
58
            headers: httpRequest.headers,
59
            readableStreamBody: res.streams.length > 0 ? res.streams[0].getStream() : undefined,
×
60
        };
61
    }
62

63
    /**
64
     * @private
65
     */
66
    private mapHttpRequestToProtocolRequest(httpRequest: WebResource): StreamingRequest {
UNCOV
67
        return StreamingRequest.create(httpRequest.method, httpRequest.url, httpRequest.body);
×
68
    }
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc