MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / headersToDict

Function headersToDict

packages/core/src/utils/request.ts:68–86  ·  view source on GitHub ↗
(
  reqHeaders: Record<string, string | string[] | undefined | number>,
)

Source from the content-addressed store, hash-verified

66 * Convert common request headers to a simple dictionary.
67 */
68export function headersToDict(
69 reqHeaders: Record<string, string | string[] | undefined | number>,
70): Record<string, string> {
71 const headers: Record<string, string> = Object.create(null);
72
73 try {
74 Object.entries(reqHeaders).forEach(([key, value]) => {
75 if (typeof value === 'string') {
76 headers[key] = value;
77 } else if (typeof value === 'number') {
78 headers[key] = String(value);
79 }
80 });
81 } catch {
82 // just return the empty headers
83 }
84
85 return headers;
86}
87
88/**
89 * Converts a `Request` object that implements the `Web Fetch API` (https://developer.mozilla.org/en-US/docs/Web/API/Headers) into the format that the `RequestData` integration understands.

Callers 4

request.test.tsFile · 0.90
endSpanFunction · 0.90
captureRequestErrorFunction · 0.90
httpRequestToRequestDataFunction · 0.85

Calls 3

createMethod · 0.65
forEachMethod · 0.65
entriesMethod · 0.65

Tested by

no test coverage detected