Merge pull request #534 from cjihrig/from-h2-headers

grpc-js-core: ignore reserved headers in fromHttp2Headers()
This commit is contained in:
Michael Lumish 2018-09-26 12:17:54 -07:00 committed by GitHub
commit 8664fd90b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -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 {

View File

@ -195,6 +195,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) => {