mirror of https://github.com/grpc/grpc-node.git
grpc-js-core: ignore reserved headers in fromHttp2Headers()
Metadata.fromHttp2Headers() throws if any reserved headers are passed. Instead of deleting headers before calling the function, this commit causes the function to ignore reserved headers.
This commit is contained in:
parent
b7b45e6dd7
commit
0c606f4408
|
@ -233,8 +233,7 @@ export class Http2CallStream extends Duplex implements Call {
|
|||
default:
|
||||
this.mappedStatusCode = Status.UNKNOWN;
|
||||
}
|
||||
delete headers[HTTP2_HEADER_STATUS];
|
||||
delete headers[HTTP2_HEADER_CONTENT_TYPE];
|
||||
|
||||
if (flags & http2.constants.NGHTTP2_FLAG_END_STREAM) {
|
||||
this.handleTrailers(headers);
|
||||
} else {
|
||||
|
|
|
@ -197,6 +197,11 @@ export class Metadata {
|
|||
static fromHttp2Headers(headers: http2.IncomingHttpHeaders): Metadata {
|
||||
const result = new Metadata();
|
||||
forOwn(headers, (values, key) => {
|
||||
// Reserved headers (beginning with `:`) are not valid keys.
|
||||
if (key.charAt(0) === ':') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBinaryKey(key)) {
|
||||
if (Array.isArray(values)) {
|
||||
values.forEach((value) => {
|
||||
|
|
Loading…
Reference in New Issue