fix(base-driver): Exclude proxied headers from the server response (#21120)

This commit is contained in:
Mykola Mokhnach
2025-03-17 19:18:19 +01:00
committed by GitHub
parent 8f5a6c47a9
commit f800c9d760
2 changed files with 1 additions and 9 deletions
@@ -428,18 +428,13 @@ export class JWProxy {
/** @type {import('@appium/types').HTTPMethod} */ (req.method),
req.body
);
for (const [name, value] of _.toPairs(response.headers)) {
if (!_.isNil(value)) {
res.setHeader(name, _.isBoolean(value) ? String(value) : value);
}
}
statusCode = response.statusCode;
} catch (err) {
[statusCode, resBodyObj] = getResponseForW3CError(
isErrorType(err, errors.ProxyRequestError) ? err.getActualError() : err
);
}
res.set('content-type', 'application/json; charset=utf-8');
res.setHeader('content-type', 'application/json; charset=utf-8');
if (!_.isPlainObject(resBodyObj)) {
const error = new errors.UnknownError(
`The downstream server response with the status code ${statusCode} is not a valid JSON object: ` +
@@ -7,9 +7,6 @@ function buildReqRes(url, method, body) {
let req = {originalUrl: url, method, body};
let res = {};
res.headers = {};
res.set = (k, v) => {
res[k] = v;
};
res.setHeader = (k, v) => {
res.headers[k] = v;
};