wdio-intercept-service
wdio-intercept-service copied to clipboard
HTTP header parsing is fundamentally wrong (in parseResponseHeaders)
wdio-intercept-service version 4.2.1
This is the header parser:
arr.forEach((header) => {
const match = header.match(/^(.+)?:\s?(.+)$/);
if (match) {
headers[match[1].toLowerCase()] = match[2];
}
});
This is the parsed header output for a simple server response:
{
"access-control-allow-origin: https": "//google.com/"
"content-security-policy: default-src 'self' https": "//google.com"
"date: wed, 23 feb 2022 14:09": "06 GMT"
"etag: '05a73f427d81": "'0'"
"last-modified: mon, 21 feb 2022 09:19": "00 GMT"
}
This lib should help you lift the burden of parsing headers: parse-headers
PRs are very welcome :)
Thanks for reporting, it was definitely not a good idea to attempt that from the hip there.
I don't have the authority to decide if you can use one more lib. But if you say it's allowed, sure, I create a PR with that npm package.
It's definitely allowed :heart:. My approach was only good for some cases, I'm actually surprised that it didn't blow up much earlier
I'm actually surprised that it didn't blow up much earlier
That was my thought, too. Alright. I'll be back with a PR tomorrow.
@christian-bromann this issue can also be closed with the release of 4.3.0
Closed in #241