mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
Merge pull request #1571 from murgatroid99/grpc-js_header_block_size
grpc-js: Allow clients and servers to send metadata of unlimited size
This commit is contained in:
commit
38e4e48f4d
@ -257,7 +257,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'],
|
||||
|
||||
@ -306,6 +306,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://';
|
||||
|
||||
@ -76,13 +76,15 @@ describe(`${anyGrpc.clientName} client -> ${anyGrpc.serverName} server`, functio
|
||||
const options = {
|
||||
'grpc.ssl_target_name_override': 'foo.test.google.fr',
|
||||
'grpc.default_authority': 'foo.test.google.fr',
|
||||
'grpc.max_send_message_length': 4*1024*1024
|
||||
'grpc.max_send_message_length': 4*1024*1024,
|
||||
'grpc.max_metadata_size': 4*1024*1024
|
||||
};
|
||||
client = new testProto.TestService(`localhost:${port}`, creds, options);
|
||||
done();
|
||||
}
|
||||
}, {
|
||||
'grpc.max_receive_message_length': -1
|
||||
'grpc.max_receive_message_length': -1,
|
||||
'grpc.max_metadata_size': 4*1024*1024
|
||||
});
|
||||
});
|
||||
after(function() {
|
||||
@ -168,6 +170,32 @@ describe(`${anyGrpc.clientName} client -> ${anyGrpc.serverName} server`, functio
|
||||
assert.ifError(error);
|
||||
});
|
||||
});
|
||||
/* The test against the JS server does not work because of
|
||||
* https://github.com/nodejs/node/issues/35218. The test against the native
|
||||
* server fails because of an unidentified timeout issue. */
|
||||
it.skip('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 grpc.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;
|
||||
|
||||
@ -52,9 +52,9 @@ const testNativeClientJsServer = runTestsWithFixture('js', 'native');
|
||||
const testJsClientJsServer = runTestsWithFixture('js', 'js');
|
||||
|
||||
const test = gulp.series(
|
||||
testJsClientJsServer,
|
||||
testJsClientNativeServer,
|
||||
testNativeClientJsServer,
|
||||
testJsClientJsServer
|
||||
testNativeClientJsServer
|
||||
);
|
||||
|
||||
export {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user