|
|
@ -1190,9 +1190,14 @@ static gpr_uint32 decode_compression(grpc_mdelem *md) { |
|
|
|
if (user_data) { |
|
|
|
if (user_data) { |
|
|
|
clevel = ((grpc_compression_level)(gpr_intptr)user_data) - COMPRESS_OFFSET; |
|
|
|
clevel = ((grpc_compression_level)(gpr_intptr)user_data) - COMPRESS_OFFSET; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (!gpr_parse_bytes_to_uint32(grpc_mdstr_as_c_string(md->value), |
|
|
|
gpr_uint32 parsed_clevel_bytes; |
|
|
|
|
|
|
|
if (gpr_parse_bytes_to_uint32(grpc_mdstr_as_c_string(md->value), |
|
|
|
GPR_SLICE_LENGTH(md->value->slice), |
|
|
|
GPR_SLICE_LENGTH(md->value->slice), |
|
|
|
&clevel)) { |
|
|
|
&parsed_clevel_bytes)) { |
|
|
|
|
|
|
|
/* the following cast is safe, as a gpr_uint32 should be able to hold all
|
|
|
|
|
|
|
|
* possible values of the grpc_compression_level enum */ |
|
|
|
|
|
|
|
clevel = (grpc_compression_level) parsed_clevel_bytes; |
|
|
|
|
|
|
|
} else { |
|
|
|
clevel = GRPC_COMPRESS_LEVEL_NONE; /* could not parse, no compression */ |
|
|
|
clevel = GRPC_COMPRESS_LEVEL_NONE; /* could not parse, no compression */ |
|
|
|
} |
|
|
|
} |
|
|
|
grpc_mdelem_set_user_data(md, destroy_compression, |
|
|
|
grpc_mdelem_set_user_data(md, destroy_compression, |
|
|
|