mirror of
https://github.com/grpc/grpc-node.git
synced 2026-02-01 14:54:35 +00:00
Warn instead of failing when constructing metadata from remote end
This commit is contained in:
parent
ad378d3681
commit
5b87ceb05c
@ -62,7 +62,7 @@ function validate(key: string, value?: MetadataValue): void {
|
||||
}
|
||||
}
|
||||
|
||||
interface MetadataOptions {
|
||||
export interface MetadataOptions {
|
||||
/* Signal that the request is idempotent. Defaults to false */
|
||||
idempotentRequest?: boolean;
|
||||
/* Signal that the call should not return UNAVAILABLE before it has
|
||||
@ -240,24 +240,29 @@ export class Metadata {
|
||||
|
||||
const values = headers[key];
|
||||
|
||||
if (isBinaryKey(key)) {
|
||||
if (Array.isArray(values)) {
|
||||
values.forEach(value => {
|
||||
result.add(key, Buffer.from(value, 'base64'));
|
||||
});
|
||||
} else if (values !== undefined) {
|
||||
values.split(',').forEach(v => {
|
||||
result.add(key, Buffer.from(v.trim(), 'base64'));
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (Array.isArray(values)) {
|
||||
values.forEach(value => {
|
||||
result.add(key, value);
|
||||
});
|
||||
} else if (values !== undefined) {
|
||||
values.split(',').forEach(v => result.add(key, v.trim()));
|
||||
try {
|
||||
if (isBinaryKey(key)) {
|
||||
if (Array.isArray(values)) {
|
||||
values.forEach(value => {
|
||||
result.add(key, Buffer.from(value, 'base64'));
|
||||
});
|
||||
} else if (values !== undefined) {
|
||||
values.split(',').forEach(v => {
|
||||
result.add(key, Buffer.from(v.trim(), 'base64'));
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (Array.isArray(values)) {
|
||||
values.forEach(value => {
|
||||
result.add(key, value);
|
||||
});
|
||||
} else if (values !== undefined) {
|
||||
values.split(',').forEach(v => result.add(key, v.trim()));
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
error.message = `Failed to add metadata entry ${key}: ${values}. ${error.message}`;
|
||||
process.emitWarning(error);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user