2017-08-30 15:52:26 -07:00
|
|
|
// Flags: --expose-internals
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
|
|
|
|
// Tests the assertValidPseudoHeader function that is used within the
|
|
|
|
// mapToHeaders function. The assert function is not exported so we
|
|
|
|
// have to test it through mapToHeaders
|
|
|
|
|
|
|
|
const { mapToHeaders } = require('internal/http2/util');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
function isNotError(val) {
|
|
|
|
assert(!(val instanceof Error));
|
|
|
|
}
|
|
|
|
|
|
|
|
function isError(val) {
|
|
|
|
common.expectsError({
|
|
|
|
code: 'ERR_HTTP2_INVALID_PSEUDOHEADER',
|
2018-04-04 20:29:52 +02:00
|
|
|
type: TypeError,
|
2017-08-30 15:52:26 -07:00
|
|
|
message: '":foo" is an invalid pseudoheader or is used incorrectly'
|
|
|
|
})(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
isNotError(mapToHeaders({ ':status': 'a' }));
|
|
|
|
isNotError(mapToHeaders({ ':path': 'a' }));
|
|
|
|
isNotError(mapToHeaders({ ':authority': 'a' }));
|
|
|
|
isNotError(mapToHeaders({ ':scheme': 'a' }));
|
|
|
|
isNotError(mapToHeaders({ ':method': 'a' }));
|
|
|
|
|
|
|
|
isError(mapToHeaders({ ':foo': 'a' }));
|