diff options
author | Muxi Yan <mxyan@google.com> | 2017-07-12 12:33:55 -0700 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2017-07-12 14:04:30 -0700 |
commit | 59827dd739c398b045e13206a5797e35ee218926 (patch) | |
tree | b52bb4daba468f32cca7d7ec8fc092519268a9e0 /tools/codegen | |
parent | 121e789f1d22a8fe3a0ff74b73d7cd9b4849d94f (diff) |
generate project
Diffstat (limited to 'tools/codegen')
-rwxr-xr-x | tools/codegen/core/gen_static_metadata.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index 8fc26a814c..0536488bcb 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -33,6 +33,7 @@ CONFIG = [ 'host', 'grpc-timeout', 'grpc-internal-encoding-request', + 'grpc-internal-stream-encoding-request', 'grpc-payload-bin', ':path', 'grpc-encoding', @@ -89,7 +90,7 @@ CONFIG = [ ('authorization', ''), ('cache-control', ''), ('content-disposition', ''), - ('content-encoding', ''), + ('content-encoding', 'gzip'), ('content-language', ''), ('content-length', ''), ('content-location', ''), @@ -145,7 +146,10 @@ METADATA_BATCH_CALLOUTS = [ 'grpc-tags-bin', 'grpc-trace-bin', 'content-type', + 'content-encoding', + 'accept-encoding', 'grpc-internal-encoding-request', + 'grpc-internal-stream-encoding-request', 'user-agent', 'host', 'lb-token', @@ -157,6 +161,10 @@ COMPRESSION_ALGORITHMS = [ 'gzip', ] +STREAM_COMPRESSION_ALGORITHMS = [ + 'identity', + 'gzip', +] # utility: mangle the name of a config def mangle(elem, name=None): @@ -251,6 +259,18 @@ for mask in range(1, 1 << len(COMPRESSION_ALGORITHMS)): all_elems.append(elem) compression_elems.append(elem) static_userdata[elem] = 1 + (mask | 1) +stream_compression_elems = [] +for mask in range(1, 1 << len(STREAM_COMPRESSION_ALGORITHMS)): + val = ','.join(STREAM_COMPRESSION_ALGORITHMS[alg] + for alg in range(0, len(STREAM_COMPRESSION_ALGORITHMS)) + if (1 << alg) & mask) + elem = ('accept-encoding', val) + if val not in all_strs: + all_strs.append(val) + if elem not in all_elems: + all_elems.append(elem) + stream_compression_elems.append(elem) + static_userdata[elem] = 1 + (mask | 1) # output configuration args = sys.argv[1:] @@ -544,6 +564,16 @@ print >> C, '};' print >> C print >> H, '#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]], GRPC_MDELEM_STORAGE_STATIC))' +print >> H + +print >> H, 'extern const uint8_t grpc_static_accept_stream_encoding_metadata[%d];' % ( + 1 << len(STREAM_COMPRESSION_ALGORITHMS)) +print >> C, 'const uint8_t grpc_static_accept_stream_encoding_metadata[%d] = {' % ( + 1 << len(STREAM_COMPRESSION_ALGORITHMS)) +print >> C, '0,%s' % ','.join('%d' % md_idx(elem) for elem in stream_compression_elems) +print >> C, '};' + +print >> H, '#define GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[grpc_static_accept_stream_encoding_metadata[(algs)]], GRPC_MDELEM_STORAGE_STATIC))' print >> H, '#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */' |