MCPcopy
hub / github.com/sindresorhus/got / createCrossOriginReceiver

Function createCrossOriginReceiver

test/helpers/server-tools.ts:27–52  ·  view source on GitHub ↗
(path = '/steal', responseBody = JSON.stringify({result: 'ok'}))

Source from the content-addressed store, hash-verified

25};
26
27export const createCrossOriginReceiver = async (path = '/steal', responseBody = JSON.stringify({result: 'ok'})) => {
28 const server = await createHttpTestServer({bodyParser: false});
29 const received = {
30 authorization: undefined as string | undefined,
31 cookie: undefined as string | undefined,
32 body: '',
33 contentType: undefined as string | undefined,
34 };
35
36 server.post(path, async (request, response) => {
37 received.authorization = request.headers.authorization;
38 received.cookie = request.headers.cookie;
39 received.body = await getStream(request);
40 received.contentType = request.headers['content-type'];
41 response.end(responseBody);
42 });
43
44 server.get(path, (request, response) => {
45 received.authorization = request.headers.authorization;
46 received.cookie = request.headers.cookie;
47 received.contentType = request.headers['content-type'];
48 response.end(responseBody);
49 });
50
51 return {server, received};
52};
53
54export const createRetryUrlServer = async (retryUrl: string, responsePath = '/api') => {
55 const server = await createHttpTestServer();

Callers 2

hooks.tsFile · 0.85

Calls 2

createHttpTestServerFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…