mirror of https://github.com/grpc/grpc-node.git
grpc-js: Allow clients and servers to send metadata of unlimited size
This commit is contained in:
parent
2445875e08
commit
d32734f491
|
@ -246,7 +246,9 @@ export class Server {
|
|||
throw new Error(`Could not get a default scheme for port "${port}"`);
|
||||
}
|
||||
|
||||
const serverOptions: http2.ServerOptions = {};
|
||||
const serverOptions: http2.ServerOptions = {
|
||||
maxSendHeaderBlockLength: Number.MAX_SAFE_INTEGER
|
||||
};
|
||||
if ('grpc.max_concurrent_streams' in this.options) {
|
||||
serverOptions.settings = {
|
||||
maxConcurrentStreams: this.options['grpc.max_concurrent_streams'],
|
||||
|
|
|
@ -291,6 +291,7 @@ export class Subchannel {
|
|||
);
|
||||
let connectionOptions: http2.SecureClientSessionOptions =
|
||||
this.credentials._getConnectionOptions() || {};
|
||||
connectionOptions.maxSendHeaderBlockLength = Number.MAX_SAFE_INTEGER;
|
||||
let addressScheme = 'http://';
|
||||
if ('secureContext' in connectionOptions) {
|
||||
addressScheme = 'https://';
|
||||
|
|
|
@ -168,6 +168,29 @@ describe(`${anyGrpc.clientName} client -> ${anyGrpc.serverName} server`, functio
|
|||
assert.ifError(error);
|
||||
});
|
||||
});
|
||||
it('should be able to send very large headers and trailers', function(done) {
|
||||
done = multiDone(done, 3);
|
||||
const header = 'X'.repeat(64 * 1024);
|
||||
const trailer = Buffer.from('Y'.repeat(64 * 1024));
|
||||
const metadata = new Metadata();
|
||||
metadata.set('x-grpc-test-echo-initial', header);
|
||||
metadata.set('x-grpc-test-echo-trailing-bin', trailer);
|
||||
const call = client.unaryCall({}, metadata, (error, result) => {
|
||||
assert.ifError(error);
|
||||
done();
|
||||
});
|
||||
call.on('metadata', (metadata) => {
|
||||
assert.deepStrictEqual(metadata.get('x-grpc-test-echo-initial'),
|
||||
[header]);
|
||||
done();
|
||||
});
|
||||
call.on('status', (status) => {
|
||||
var echo_trailer = status.metadata.get('x-grpc-test-echo-trailing-bin');
|
||||
assert(echo_trailer.length === 1);
|
||||
assert.strictEqual(echo_trailer[0].toString('ascii'), 'Y'.repeat(64 * 1024));
|
||||
done();
|
||||
});
|
||||
});
|
||||
describe('max message size', function() {
|
||||
// A size that is larger than the default limit
|
||||
const largeMessageSize = 8 * 1024 * 1024;
|
||||
|
|
Loading…
Reference in New Issue