MCPcopy
hub / github.com/mitmproxy/mitmproxy / get_first_header

Method get_first_header

web/src/js/flow/utils.ts:21–39  ·  view source on GitHub ↗
(
        message: HTTPMessage,
        regex: RegExp,
    )

Source from the content-addressed store, hash-verified

19 }
20
21 static get_first_header(
22 message: HTTPMessage,
23 regex: RegExp,
24 ): string | undefined {
25 let messageLookups = _headerLookups.get(message);
26 if (!messageLookups) {
27 messageLookups = new Map();
28 _headerLookups.set(message, messageLookups);
29 }
30 let ret = messageLookups.get(regex);
31 if (ret === undefined) {
32 const header = message.headers.find(([name, _]) =>
33 regex.test(name),
34 );
35 ret = header ? header[1] : false;
36 messageLookups.set(regex, ret);
37 }
38 return ret !== false ? ret : undefined;
39 }
40
41 static match_header(message, regex) {
42 const headers = message.headers;

Callers 3

getContentTypeMethod · 0.45
TrailersFunction · 0.45
utilsSpec.tsxFile · 0.45

Calls 4

testMethod · 0.80
getMethod · 0.45
setMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected