MCPcopy Index your code
hub / github.com/tensorflow/tfjs / parseHeaders

Function parseHeaders

tfjs-react-native/src/platform_react_native.ts:33–47  ·  view source on GitHub ↗
(rawHeaders: string)

Source from the content-addressed store, hash-verified

31// tslint:disable-next-line:max-line-length
32// https://github.com/facebook/react-native/blob/0ee5f68929610106ee6864baa04ea90be0fc5160/Libraries/vendor/core/whatwg-fetch.js#L421
33function parseHeaders(rawHeaders: string) {
34 const headers = new Headers();
35 // Replace instances of \r\n and \n followed by at least one space or
36 // horizontal tab with a space https://tools.ietf.org/html/rfc7230#section-3.2
37 const preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
38 preProcessedHeaders.split(/\r?\n/).forEach((line) => {
39 const parts = line.split(":");
40 const key = parts.shift().trim();
41 if (key) {
42 const value = parts.join(":").trim();
43 headers.append(key, value);
44 }
45 });
46 return headers;
47}
48
49// Implementation note: This is a patch of react-native's fetch implementation
50// tslint:disable-next-line:max-line-length

Callers 1

fetchFunction · 0.85

Calls 4

shiftMethod · 0.80
joinMethod · 0.80
appendMethod · 0.80
splitMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…