MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / encodeWebRequestHeader

Function encodeWebRequestHeader

src/background/utils/requests-core.js:147–153  ·  view source on GitHub ↗

* Imitating https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/getAllResponseHeaders * Per the specification https://tools.ietf.org/html/rfc7230 the header name is within ASCII, * but we'll try encoding it, if necessary, to handle invalid server responses.

({ name, value, binaryValue })

Source from the content-addressed store, hash-verified

145 * but we'll try encoding it, if necessary, to handle invalid server responses.
146 */
147function encodeWebRequestHeader({ name, value, binaryValue }) {
148 return `${string2byteString(name)}: ${
149 binaryValue
150 ? buffer2string(binaryValue)
151 : string2byteString(value)
152 }\r\n`;
153}
154
155/**
156 * @param {string} headerValue

Callers

nothing calls this directly

Calls 2

buffer2stringFunction · 0.90
string2byteStringFunction · 0.85

Tested by

no test coverage detected