MCPcopy Create free account
hub / github.com/ShipSecAI/studio / getBodyText

Function getBodyText

packages/component-sdk/src/http/har-builder.ts:24–50  ·  view source on GitHub ↗
(body: RequestInit['body'] | null | undefined)

Source from the content-addressed store, hash-verified

22 new Set(headers.map((header) => header.toLowerCase()));
23
24const getBodyText = (body: RequestInit['body'] | null | undefined): string | undefined => {
25 if (!body) {
26 return undefined;
27 }
28
29 if (typeof body === 'string') {
30 return body;
31 }
32
33 if (typeof URLSearchParams !== 'undefined' && body instanceof URLSearchParams) {
34 return body.toString();
35 }
36
37 if (typeof ArrayBuffer !== 'undefined' && body instanceof ArrayBuffer) {
38 return Buffer.from(body).toString('utf8');
39 }
40
41 if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView(body)) {
42 return Buffer.from(body.buffer, body.byteOffset, body.byteLength).toString('utf8');
43 }
44
45 if (typeof Buffer !== 'undefined' && Buffer.isBuffer(body)) {
46 return body.toString('utf8');
47 }
48
49 return undefined;
50};
51
52export function headersToHar(headers: HttpHeaders | Record<string, string>): HarHeader[] {
53 const entries: HarHeader[] = [];

Callers 1

buildHarRequestFunction · 0.85

Calls 1

fromMethod · 0.80

Tested by

no test coverage detected