Skip to content

Commit

Permalink
Compare Engine reporting's privateHeaders case-insensitively, as do…
Browse files Browse the repository at this point in the history
…cumented.

The documentation for `privateHeaders`[[0]] suggests that it is
case-insensitive.  While that statement is true, and the incoming header is
lower-cased before checking it against the `privateHeaders` configuration,
it assumed that the headers in the `privateHeaders` object were specified in
lower-case.

This changes the comparison to lower-case both sides prior to determining
equality.

[0]: https://github.com/apollographql/apollo-server/blob/abb8dc58/packages/apollo-engine-reporting/src/agent.ts#L67-L70

Fixes: #2273
  • Loading branch information
abernix committed Feb 6, 2019
1 parent 3dfbfcc commit 927fe47
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/apollo-engine-reporting/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ export class EngineReportingExtension<TContext = any>
// We assume that most users only have a few private headers, or will
// just set privateHeaders to true; we can change this linear-time
// operation if it causes real performance issues.
this.options.privateHeaders.includes(key.toLowerCase())
this.options.privateHeaders.some((privateHeader) => {
// Headers are case-insensitive, and should be compared as such.
return privateHeader.toLowerCase() === key.toLowerCase();
})
) {
continue;
}
Expand Down

0 comments on commit 927fe47

Please sign in to comment.