grpc 1.39.0 → 1.41.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +45 -38
- data/include/grpc/byte_buffer.h +1 -1
- data/include/grpc/byte_buffer_reader.h +1 -1
- data/include/grpc/event_engine/endpoint_config.h +6 -11
- data/include/grpc/event_engine/event_engine.h +73 -72
- data/include/grpc/event_engine/port.h +1 -3
- data/include/grpc/event_engine/slice_allocator.h +14 -34
- data/include/grpc/fork.h +1 -1
- data/include/grpc/grpc.h +10 -4
- data/include/grpc/grpc_posix.h +5 -2
- data/include/grpc/impl/codegen/atm.h +5 -3
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +2 -0
- data/include/grpc/impl/codegen/atm_gcc_sync.h +2 -0
- data/include/grpc/impl/codegen/atm_windows.h +2 -0
- data/include/grpc/impl/codegen/byte_buffer.h +2 -0
- data/include/grpc/impl/codegen/byte_buffer_reader.h +2 -0
- data/include/grpc/impl/codegen/compression_types.h +2 -0
- data/include/grpc/impl/codegen/connectivity_state.h +2 -0
- data/include/grpc/impl/codegen/fork.h +2 -0
- data/include/grpc/impl/codegen/gpr_slice.h +2 -0
- data/include/grpc/impl/codegen/gpr_types.h +2 -0
- data/include/grpc/impl/codegen/grpc_types.h +22 -13
- data/include/grpc/impl/codegen/log.h +2 -0
- data/include/grpc/impl/codegen/port_platform.h +50 -22
- data/include/grpc/impl/codegen/propagation_bits.h +2 -0
- data/include/grpc/impl/codegen/slice.h +2 -0
- data/include/grpc/impl/codegen/status.h +2 -0
- data/include/grpc/impl/codegen/sync.h +8 -5
- data/include/grpc/impl/codegen/sync_abseil.h +2 -0
- data/include/grpc/impl/codegen/sync_custom.h +2 -0
- data/include/grpc/impl/codegen/sync_generic.h +3 -0
- data/include/grpc/impl/codegen/sync_posix.h +4 -2
- data/include/grpc/impl/codegen/sync_windows.h +2 -0
- data/include/grpc/slice.h +1 -1
- data/include/grpc/status.h +1 -1
- data/include/grpc/support/atm.h +1 -1
- data/include/grpc/support/atm_gcc_atomic.h +1 -1
- data/include/grpc/support/atm_gcc_sync.h +1 -1
- data/include/grpc/support/atm_windows.h +1 -1
- data/include/grpc/support/log.h +1 -1
- data/include/grpc/support/port_platform.h +1 -1
- data/include/grpc/support/sync.h +1 -1
- data/include/grpc/support/sync_abseil.h +1 -1
- data/include/grpc/support/sync_custom.h +1 -1
- data/include/grpc/support/sync_generic.h +1 -1
- data/include/grpc/support/sync_posix.h +1 -1
- data/include/grpc/support/sync_windows.h +1 -1
- data/include/grpc/support/time.h +2 -2
- data/src/core/ext/filters/census/grpc_context.cc +1 -0
- data/src/core/ext/filters/client_channel/backend_metric.cc +0 -1
- data/src/core/ext/filters/client_channel/backup_poller.h +1 -0
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +1 -2
- data/src/core/ext/filters/client_channel/client_channel.cc +437 -299
- data/src/core/ext/filters/client_channel/client_channel.h +45 -21
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +6 -5
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +1 -0
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +8 -1
- data/src/core/ext/filters/client_channel/config_selector.cc +1 -0
- data/src/core/ext/filters/client_channel/config_selector.h +19 -6
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +7 -6
- data/src/core/ext/filters/client_channel/health/health_check_client.h +4 -3
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +8 -7
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +10 -2
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +2 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +9 -16
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +2 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +2 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +2 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +12 -21
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +17 -28
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +18 -38
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +8 -15
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +2 -2
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +5 -14
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +23 -30
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +24 -29
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +4 -17
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +7 -11
- data/src/core/ext/filters/client_channel/lb_policy.cc +1 -15
- data/src/core/ext/filters/client_channel/lb_policy.h +81 -90
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +4 -7
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +2 -10
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +4 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +6 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +14 -19
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -0
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +5 -5
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +106 -81
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +2 -3
- data/src/core/ext/filters/client_channel/retry_filter.cc +408 -246
- data/src/core/ext/filters/client_channel/retry_service_config.cc +36 -26
- data/src/core/ext/filters/client_channel/retry_service_config.h +1 -1
- data/src/core/ext/filters/client_channel/service_config_call_data.h +45 -5
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +36 -30
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +8 -12
- data/src/core/ext/filters/fault_injection/service_config_parser.cc +6 -13
- data/src/core/ext/filters/http/client/http_client_filter.cc +8 -4
- data/src/core/ext/filters/http/client_authority_filter.cc +2 -1
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +2 -1
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +7 -8
- data/src/core/ext/filters/http/server/http_server_filter.cc +5 -3
- data/src/core/ext/filters/message_size/message_size_filter.cc +9 -13
- data/src/core/ext/transport/chttp2/alpn/alpn.cc +2 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +29 -12
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +2 -0
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +2 -3
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +10 -6
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +2 -3
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +65 -38
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +0 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +12 -6
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +5 -9
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +4 -2
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +2 -1
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +1 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.cc +67 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h +74 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +26 -36
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +4 -1
- data/src/core/ext/transport/chttp2/transport/context_list.h +1 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +39 -23
- data/src/core/ext/transport/chttp2/transport/flow_control.h +10 -4
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +11 -11
- data/src/core/ext/transport/chttp2/transport/frame_data.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +12 -11
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +3 -5
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +41 -10
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +12 -7
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +1 -0
- data/src/core/ext/transport/chttp2/transport/hpack_constants.h +41 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +272 -666
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +236 -70
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_index.h +107 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +86 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +69 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +821 -1195
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +76 -76
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +159 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +130 -0
- data/src/core/ext/transport/chttp2/transport/hpack_utils.cc +46 -0
- data/src/core/ext/transport/chttp2/transport/hpack_utils.h +30 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +3 -3
- data/src/core/ext/transport/chttp2/transport/parsing.cc +89 -83
- data/src/core/ext/transport/chttp2/transport/popularity_count.h +60 -0
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/varint.cc +13 -7
- data/src/core/ext/transport/chttp2/transport/varint.h +39 -28
- data/src/core/ext/transport/chttp2/transport/writing.cc +32 -28
- data/src/core/ext/transport/inproc/inproc_transport.cc +6 -4
- data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c +96 -96
- data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.h +221 -89
- data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +1 -1
- data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +48 -48
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +151 -61
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +117 -96
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +347 -141
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +15 -15
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +133 -126
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +326 -149
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c +23 -23
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +28 -28
- data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +71 -29
- data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +114 -78
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +268 -88
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +24 -24
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +51 -21
- data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +9 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +21 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +62 -62
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +131 -53
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +51 -51
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +81 -33
- data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +110 -53
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +356 -45
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c +46 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.h +133 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +9 -8
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c +35 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.h +96 -0
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +16 -16
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +57 -22
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +174 -17
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +32 -32
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +51 -21
- data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +45 -37
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +177 -94
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +42 -40
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +86 -29
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +48 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +177 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +10 -8
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +48 -28
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c +30 -30
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.h +81 -33
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +41 -29
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +141 -43
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +47 -43
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +88 -29
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +34 -17
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +84 -9
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +293 -277
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +633 -240
- data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +10 -10
- data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +6 -6
- data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +21 -9
- data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c +13 -13
- data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.h +51 -21
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +24 -23
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +35 -13
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +10 -9
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +26 -16
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +147 -106
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +457 -160
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.h +1 -1
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +48 -31
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +135 -34
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +12 -12
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +44 -42
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +108 -55
- data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +42 -42
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +61 -25
- data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +9 -9
- data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +21 -9
- data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +48 -20
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +162 -17
- data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c +60 -0
- data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.h +205 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +9 -8
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +25 -9
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +11 -5
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +10 -9
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +10 -10
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +21 -9
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c +6 -6
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.h +21 -9
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +11 -11
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +15 -15
- data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +71 -29
- data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +19 -19
- data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +51 -21
- data/src/core/ext/upb-generated/envoy/type/v3/http.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/type/v3/http.upb.h +1 -1
- data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.c +6 -6
- data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +21 -9
- data/src/core/ext/upb-generated/envoy/type/v3/range.upb.c +10 -10
- data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +31 -13
- data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +11 -5
- data/src/core/ext/upb-generated/google/api/annotations.upb.c +1 -1
- data/src/core/ext/upb-generated/google/api/annotations.upb.h +1 -1
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +58 -58
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +111 -45
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +68 -68
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +121 -49
- data/src/core/ext/upb-generated/google/api/http.upb.c +18 -18
- data/src/core/ext/upb-generated/google/api/http.upb.h +31 -13
- data/src/core/ext/upb-generated/google/protobuf/any.upb.c +4 -4
- data/src/core/ext/upb-generated/google/protobuf/any.upb.h +11 -5
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +153 -153
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +271 -109
- data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +4 -4
- data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +11 -5
- data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +2 -2
- data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +11 -5
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +15 -15
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +31 -13
- data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +4 -4
- data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +11 -5
- data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +19 -19
- data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +91 -37
- data/src/core/ext/upb-generated/google/rpc/status.upb.c +5 -5
- data/src/core/ext/upb-generated/google/rpc/status.upb.h +11 -5
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +12 -12
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +11 -5
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +60 -60
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +101 -41
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +7 -7
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +21 -9
- data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +5 -5
- data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +21 -9
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +31 -31
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +91 -37
- data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +8 -8
- data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +31 -13
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +4 -4
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +11 -5
- data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.c +1 -1
- data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +1 -1
- data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +4 -4
- data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +11 -5
- data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +3 -3
- data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +11 -5
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +13 -13
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +11 -5
- data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.c +4 -4
- data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.h +11 -5
- data/src/core/ext/upb-generated/validate/validate.upb.c +240 -224
- data/src/core/ext/upb-generated/validate/validate.upb.h +451 -217
- data/src/core/ext/upb-generated/xds/core/v3/authority.upb.c +3 -3
- data/src/core/ext/upb-generated/xds/core/v3/authority.upb.h +11 -5
- data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.c +8 -8
- data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.h +21 -9
- data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.c +6 -6
- data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.h +11 -5
- data/src/core/ext/upb-generated/xds/core/v3/resource.upb.c +5 -5
- data/src/core/ext/upb-generated/xds/core/v3/resource.upb.h +11 -5
- data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.c +11 -11
- data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.h +21 -9
- data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.c +6 -6
- data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.h +11 -5
- data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c +15 -7
- data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +53 -52
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +318 -277
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +438 -409
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +198 -170
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +10 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +9 -8
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +219 -163
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +15 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.c +59 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +29 -25
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.c +52 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +94 -63
- data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.h +10 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +135 -125
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +131 -123
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c +90 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +32 -24
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c +30 -19
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +69 -55
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +796 -765
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +13 -10
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +13 -10
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +436 -374
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +10 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +140 -114
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +178 -173
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +112 -79
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.c +64 -0
- data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.h +50 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.c +14 -13
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +35 -32
- data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.c +103 -103
- data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c +4 -4
- data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +182 -160
- data/src/core/ext/xds/certificate_provider_registry.cc +2 -2
- data/src/core/ext/xds/certificate_provider_store.h +1 -1
- data/src/core/ext/xds/xds_api.cc +1116 -1054
- data/src/core/ext/xds/xds_api.h +47 -35
- data/src/core/ext/xds/xds_bootstrap.cc +29 -51
- data/src/core/ext/xds/xds_client.cc +130 -68
- data/src/core/ext/xds/xds_client.h +0 -4
- data/src/core/ext/xds/xds_client_stats.cc +16 -15
- data/src/core/ext/xds/xds_client_stats.h +6 -6
- data/src/core/ext/xds/xds_http_fault_filter.cc +4 -3
- data/src/core/ext/xds/xds_http_fault_filter.h +3 -2
- data/src/core/ext/xds/xds_http_filters.cc +4 -2
- data/src/core/ext/xds/xds_http_filters.h +3 -0
- data/src/core/ext/xds/xds_server_config_fetcher.cc +10 -10
- data/src/core/lib/address_utils/parse_address.cc +4 -8
- data/src/core/lib/address_utils/sockaddr_utils.cc +2 -2
- data/src/core/lib/channel/call_tracer.h +85 -0
- data/src/core/lib/channel/channel_args.cc +2 -1
- data/src/core/lib/channel/channel_stack.cc +5 -3
- data/src/core/lib/channel/channel_stack.h +1 -1
- data/src/core/lib/channel/channel_stack_builder.cc +1 -11
- data/src/core/lib/channel/channel_stack_builder.h +0 -8
- data/src/core/lib/channel/channel_trace.cc +4 -3
- data/src/core/lib/channel/channel_trace.h +1 -0
- data/src/core/lib/channel/channelz.cc +40 -36
- data/src/core/lib/channel/channelz.h +27 -27
- data/src/core/lib/channel/channelz_registry.cc +7 -6
- data/src/core/lib/channel/connected_channel.cc +1 -0
- data/src/core/lib/channel/context.h +3 -0
- data/src/core/lib/channel/handshaker.cc +2 -1
- data/src/core/lib/channel/handshaker.h +1 -2
- data/src/core/lib/channel/handshaker_factory.h +10 -2
- data/src/core/lib/channel/handshaker_registry.cc +15 -70
- data/src/core/lib/channel/handshaker_registry.h +29 -12
- data/src/core/lib/channel/status_util.h +6 -2
- data/src/core/lib/compression/algorithm_metadata.h +1 -0
- data/src/core/lib/compression/compression_args.cc +2 -1
- data/src/core/lib/compression/compression_internal.cc +2 -4
- data/src/core/lib/compression/message_compress.cc +2 -2
- data/src/core/lib/compression/stream_compression.cc +2 -1
- data/src/core/lib/compression/stream_compression.h +3 -2
- data/src/core/lib/compression/stream_compression_gzip.cc +2 -1
- data/src/core/lib/compression/stream_compression_gzip.h +1 -1
- data/src/core/lib/compression/stream_compression_identity.cc +2 -1
- data/src/core/lib/compression/stream_compression_identity.h +1 -1
- data/src/core/lib/config/core_configuration.cc +54 -0
- data/src/core/lib/config/core_configuration.h +108 -0
- data/src/core/lib/debug/stats.h +2 -1
- data/src/core/lib/debug/stats_data.cc +2 -1
- data/src/core/lib/debug/stats_data.h +1 -0
- data/src/core/lib/debug/trace.cc +1 -0
- data/src/core/lib/debug/trace.h +2 -1
- data/src/core/lib/event_engine/endpoint_config.cc +0 -1
- data/src/core/lib/event_engine/event_engine.cc +3 -3
- data/src/core/lib/event_engine/sockaddr.cc +3 -3
- data/src/core/lib/gpr/alloc.cc +4 -3
- data/src/core/lib/gpr/env_linux.cc +1 -2
- data/src/core/lib/gpr/env_posix.cc +2 -3
- data/src/core/lib/gpr/log.cc +3 -3
- data/src/core/lib/gpr/log_android.cc +3 -2
- data/src/core/lib/gpr/log_linux.cc +7 -4
- data/src/core/lib/gpr/log_posix.cc +6 -3
- data/src/core/lib/gpr/murmur_hash.cc +4 -2
- data/src/core/lib/gpr/string.h +2 -2
- data/src/core/lib/gpr/sync.cc +2 -2
- data/src/core/lib/gpr/sync_abseil.cc +7 -6
- data/src/core/lib/gpr/sync_posix.cc +3 -3
- data/src/core/lib/gpr/time.cc +3 -2
- data/src/core/lib/gpr/time_windows.cc +3 -2
- data/src/core/lib/gpr/tls.h +120 -41
- data/src/core/lib/gpr/tmpfile_posix.cc +1 -2
- data/src/core/lib/gprpp/arena.cc +2 -1
- data/src/core/lib/gprpp/arena.h +5 -5
- data/src/core/lib/gprpp/atomic_utils.h +47 -0
- data/src/core/lib/gprpp/bitset.h +166 -0
- data/src/core/lib/gprpp/construct_destruct.h +39 -0
- data/src/core/lib/gprpp/dual_ref_counted.h +25 -26
- data/src/core/lib/gprpp/fork.cc +14 -12
- data/src/core/lib/gprpp/fork.h +4 -4
- data/src/core/lib/gprpp/global_config.h +1 -2
- data/src/core/lib/gprpp/global_config_env.cc +7 -7
- data/src/core/lib/gprpp/global_config_generic.h +2 -2
- data/src/core/lib/gprpp/manual_constructor.h +9 -6
- data/src/core/lib/gprpp/match.h +73 -0
- data/src/core/lib/gprpp/memory.h +3 -3
- data/src/core/lib/gprpp/mpscq.cc +7 -7
- data/src/core/lib/gprpp/mpscq.h +6 -5
- data/src/core/lib/gprpp/orphanable.h +6 -6
- data/src/core/lib/gprpp/overload.h +59 -0
- data/src/core/lib/gprpp/ref_counted.h +18 -18
- data/src/core/lib/gprpp/status_helper.cc +4 -4
- data/src/core/lib/gprpp/sync.h +5 -31
- data/src/core/lib/gprpp/thd_posix.cc +5 -5
- data/src/core/lib/gprpp/thd_windows.cc +4 -11
- data/src/core/lib/gprpp/time_util.cc +2 -2
- data/src/core/lib/gprpp/time_util.h +2 -2
- data/src/core/lib/http/format_request.cc +1 -0
- data/src/core/lib/http/format_request.h +1 -0
- data/src/core/lib/http/httpcli.cc +9 -9
- data/src/core/lib/http/httpcli.h +3 -0
- data/src/core/lib/http/httpcli_security_connector.cc +5 -8
- data/src/core/lib/http/parser.h +1 -0
- data/src/core/lib/iomgr/buffer_list.cc +3 -2
- data/src/core/lib/iomgr/buffer_list.h +1 -2
- data/src/core/lib/iomgr/call_combiner.cc +1 -0
- data/src/core/lib/iomgr/cfstream_handle.cc +1 -1
- data/src/core/lib/iomgr/combiner.cc +3 -2
- data/src/core/lib/iomgr/combiner.h +1 -0
- data/src/core/lib/iomgr/dualstack_socket_posix.cc +1 -0
- data/src/core/lib/iomgr/endpoint.cc +0 -4
- data/src/core/lib/iomgr/endpoint.h +1 -3
- data/src/core/lib/iomgr/endpoint_cfstream.cc +9 -20
- data/src/core/lib/iomgr/endpoint_cfstream.h +1 -1
- data/src/core/lib/iomgr/endpoint_pair.h +1 -0
- data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +1 -2
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +15 -11
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +17 -9
- data/src/core/lib/iomgr/error.h +23 -9
- data/src/core/lib/iomgr/error_cfstream.cc +2 -2
- data/src/core/lib/iomgr/error_internal.h +1 -0
- data/src/core/lib/iomgr/ev_apple.h +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +14 -22
- data/src/core/lib/iomgr/ev_epollex_linux.cc +15 -22
- data/src/core/lib/iomgr/ev_poll_posix.cc +13 -25
- data/src/core/lib/iomgr/ev_posix.cc +1 -2
- data/src/core/lib/iomgr/event_engine/endpoint.cc +9 -30
- data/src/core/lib/iomgr/event_engine/endpoint.h +1 -2
- data/src/core/lib/iomgr/event_engine/iomgr.cc +17 -18
- data/src/core/lib/iomgr/event_engine/iomgr.h +20 -2
- data/src/core/lib/iomgr/event_engine/resolver.cc +2 -1
- data/src/core/lib/iomgr/event_engine/tcp.cc +68 -19
- data/src/core/lib/iomgr/exec_ctx.cc +3 -4
- data/src/core/lib/iomgr/exec_ctx.h +11 -19
- data/src/core/lib/iomgr/executor/mpmcqueue.cc +10 -9
- data/src/core/lib/iomgr/executor/mpmcqueue.h +4 -3
- data/src/core/lib/iomgr/executor/threadpool.cc +2 -2
- data/src/core/lib/iomgr/executor/threadpool.h +2 -1
- data/src/core/lib/iomgr/executor.cc +5 -6
- data/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc +2 -2
- data/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc +2 -2
- data/src/core/lib/iomgr/internal_errqueue.cc +3 -2
- data/src/core/lib/iomgr/iocp_windows.cc +1 -0
- data/src/core/lib/iomgr/iomgr.h +2 -2
- data/src/core/lib/iomgr/iomgr_custom.cc +2 -2
- data/src/core/lib/iomgr/iomgr_custom.h +2 -2
- data/src/core/lib/iomgr/iomgr_internal.cc +2 -1
- data/src/core/lib/iomgr/iomgr_windows.cc +1 -2
- data/src/core/lib/iomgr/is_epollexclusive_available.cc +4 -4
- data/src/core/lib/iomgr/polling_entity.cc +2 -2
- data/src/core/lib/iomgr/pollset_custom.cc +3 -4
- data/src/core/lib/iomgr/pollset_custom.h +2 -2
- data/src/core/lib/iomgr/pollset_set_custom.cc +1 -2
- data/src/core/lib/iomgr/pollset_set_windows.cc +1 -0
- data/src/core/lib/iomgr/port.h +0 -5
- data/src/core/lib/iomgr/python_util.h +2 -1
- data/src/core/lib/iomgr/resolve_address.cc +2 -1
- data/src/core/lib/iomgr/resolve_address.h +0 -4
- data/src/core/lib/iomgr/resolve_address_custom.cc +4 -4
- data/src/core/lib/iomgr/resolve_address_custom.h +0 -1
- data/src/core/lib/iomgr/resolve_address_posix.cc +2 -4
- data/src/core/lib/iomgr/resolve_address_windows.cc +6 -8
- data/src/core/lib/iomgr/resource_quota.cc +127 -40
- data/src/core/lib/iomgr/resource_quota.h +66 -17
- data/src/core/lib/iomgr/sockaddr.h +1 -1
- data/src/core/lib/iomgr/socket_factory_posix.cc +3 -3
- data/src/core/lib/iomgr/socket_factory_posix.h +1 -0
- data/src/core/lib/iomgr/socket_mutator.h +2 -2
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +3 -3
- data/src/core/lib/iomgr/socket_utils_linux.cc +4 -4
- data/src/core/lib/iomgr/socket_utils_posix.cc +2 -2
- data/src/core/lib/iomgr/socket_utils_posix.h +2 -2
- data/src/core/lib/iomgr/socket_utils_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_client.cc +4 -2
- data/src/core/lib/iomgr/tcp_client.h +4 -0
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +9 -19
- data/src/core/lib/iomgr/tcp_client_custom.cc +9 -17
- data/src/core/lib/iomgr/tcp_client_posix.cc +24 -9
- data/src/core/lib/iomgr/tcp_client_posix.h +5 -2
- data/src/core/lib/iomgr/tcp_client_windows.cc +16 -6
- data/src/core/lib/iomgr/tcp_custom.cc +11 -23
- data/src/core/lib/iomgr/tcp_custom.h +2 -1
- data/src/core/lib/iomgr/tcp_posix.cc +29 -59
- data/src/core/lib/iomgr/tcp_posix.h +11 -12
- data/src/core/lib/iomgr/tcp_server.cc +6 -4
- data/src/core/lib/iomgr/tcp_server.h +12 -9
- data/src/core/lib/iomgr/tcp_server_custom.cc +15 -33
- data/src/core/lib/iomgr/tcp_server_posix.cc +21 -13
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +3 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -2
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +3 -4
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +4 -4
- data/src/core/lib/iomgr/tcp_server_windows.cc +13 -9
- data/src/core/lib/iomgr/tcp_windows.cc +6 -25
- data/src/core/lib/iomgr/tcp_windows.h +2 -1
- data/src/core/lib/iomgr/timer.cc +1 -0
- data/src/core/lib/iomgr/timer.h +1 -2
- data/src/core/lib/iomgr/timer_custom.cc +2 -2
- data/src/core/lib/iomgr/timer_generic.cc +8 -38
- data/src/core/lib/iomgr/timer_generic.h +1 -0
- data/src/core/lib/iomgr/timer_heap.cc +1 -2
- data/src/core/lib/iomgr/timer_manager.cc +1 -1
- data/src/core/lib/iomgr/udp_server.cc +1 -2
- data/src/core/lib/iomgr/unix_sockets_posix.cc +3 -5
- data/src/core/lib/iomgr/unix_sockets_posix.h +2 -3
- data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -0
- data/src/core/lib/iomgr/wakeup_fd_pipe.cc +2 -3
- data/src/core/lib/iomgr/wakeup_fd_posix.cc +1 -0
- data/src/core/lib/iomgr/work_serializer.cc +4 -4
- data/src/core/lib/iomgr/work_serializer.h +1 -1
- data/src/core/lib/json/json_reader.cc +10 -19
- data/src/core/lib/json/json_util.h +18 -26
- data/src/core/lib/matchers/matchers.cc +8 -20
- data/src/core/lib/matchers/matchers.h +2 -2
- data/src/core/lib/profiling/basic_timers.cc +8 -6
- data/src/core/lib/profiling/stap_timers.cc +2 -2
- data/src/core/lib/security/authorization/authorization_policy_provider.h +5 -4
- data/src/core/lib/security/authorization/evaluate_args.cc +2 -0
- data/src/core/lib/security/authorization/sdk_server_authz_filter.cc +159 -0
- data/src/core/lib/security/authorization/sdk_server_authz_filter.h +67 -0
- data/src/core/lib/security/context/security_context.cc +7 -6
- data/src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc +2 -2
- data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +2 -2
- data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +2 -2
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +4 -3
- data/src/core/lib/security/credentials/credentials.cc +6 -6
- data/src/core/lib/security/credentials/credentials.h +1 -1
- data/src/core/lib/security/credentials/credentials_metadata.cc +2 -3
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +13 -26
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +1 -2
- data/src/core/lib/security/credentials/external/aws_request_signer.cc +3 -3
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +13 -22
- data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +2 -4
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +1 -2
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +55 -3
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +2 -1
- data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
- data/src/core/lib/security/credentials/jwt/json_token.h +2 -1
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +31 -14
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +11 -3
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +0 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +3 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +3 -7
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +1 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +2 -4
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +4 -4
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +0 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +3 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +10 -6
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +50 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +14 -5
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +2 -2
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +4 -6
- data/src/core/lib/security/security_connector/load_system_roots_fallback.cc +1 -0
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +3 -3
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +4 -7
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +1 -2
- data/src/core/lib/security/security_connector/ssl_utils.cc +2 -3
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +15 -32
- data/src/core/lib/security/transport/auth_filters.h +1 -0
- data/src/core/lib/security/transport/client_auth_filter.cc +4 -6
- data/src/core/lib/security/transport/secure_endpoint.cc +4 -14
- data/src/core/lib/security/transport/secure_endpoint.h +1 -0
- data/src/core/lib/security/transport/security_handshaker.cc +17 -8
- data/src/core/lib/security/transport/security_handshaker.h +2 -1
- data/src/core/lib/security/transport/server_auth_filter.cc +0 -7
- data/src/core/lib/security/util/json_util.cc +6 -8
- data/src/core/lib/slice/percent_encoding.cc +73 -30
- data/src/core/lib/slice/percent_encoding.h +29 -28
- data/src/core/lib/slice/slice.cc +14 -5
- data/src/core/lib/slice/slice_buffer.cc +1 -2
- data/src/core/lib/slice/slice_intern.cc +2 -3
- data/src/core/lib/slice/slice_internal.h +3 -2
- data/src/core/lib/surface/api_trace.cc +2 -1
- data/src/core/lib/surface/api_trace.h +1 -0
- data/src/core/lib/surface/byte_buffer_reader.cc +1 -1
- data/src/core/lib/surface/call.cc +14 -14
- data/src/core/lib/surface/call.h +3 -3
- data/src/core/lib/surface/call_details.cc +2 -2
- data/src/core/lib/surface/call_log_batch.cc +2 -2
- data/src/core/lib/surface/channel.cc +22 -9
- data/src/core/lib/surface/channel.h +14 -2
- data/src/core/lib/surface/channel_ping.cc +1 -2
- data/src/core/lib/surface/channel_stack_type.cc +2 -1
- data/src/core/lib/surface/completion_queue.cc +54 -64
- data/src/core/lib/surface/completion_queue_factory.cc +2 -1
- data/src/core/lib/surface/completion_queue_factory.h +1 -0
- data/src/core/lib/surface/event_string.cc +1 -0
- data/src/core/lib/surface/init.cc +4 -9
- data/src/core/lib/surface/init.h +0 -1
- data/src/core/lib/surface/init_secure.cc +23 -4
- data/src/core/lib/surface/lame_client.cc +6 -5
- data/src/core/lib/surface/metadata_array.cc +2 -2
- data/src/core/lib/surface/server.cc +20 -34
- data/src/core/lib/surface/server.h +14 -16
- data/src/core/lib/surface/validate_metadata.cc +44 -16
- data/src/core/lib/surface/version.cc +2 -4
- data/src/core/lib/transport/byte_stream.h +1 -0
- data/src/core/lib/transport/connectivity_state.cc +8 -5
- data/src/core/lib/transport/connectivity_state.h +2 -2
- data/src/core/lib/transport/error_utils.cc +1 -0
- data/src/core/lib/transport/metadata.cc +10 -10
- data/src/core/lib/transport/metadata.h +13 -11
- data/src/core/lib/transport/metadata_batch.cc +13 -2
- data/src/core/lib/transport/metadata_batch.h +15 -0
- data/src/core/lib/transport/transport_op_string.cc +2 -2
- data/src/core/plugin_registry/grpc_plugin_registry.cc +14 -0
- data/src/core/tsi/alts/crypt/aes_gcm.cc +3 -2
- data/src/core/tsi/alts/crypt/gsec.h +2 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +2 -2
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +2 -3
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc +2 -2
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +4 -3
- data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +2 -2
- data/src/core/tsi/ssl_transport_security.cc +11 -9
- data/src/core/tsi/ssl_transport_security.h +3 -1
- data/src/core/tsi/transport_security.cc +3 -3
- data/src/core/tsi/transport_security_grpc.h +1 -0
- data/src/ruby/ext/grpc/extconf.rb +1 -1
- data/src/ruby/ext/grpc/rb_byte_buffer.c +2 -1
- data/src/ruby/ext/grpc/rb_call.c +5 -5
- data/src/ruby/ext/grpc/rb_call_credentials.c +5 -5
- data/src/ruby/ext/grpc/rb_channel.c +10 -8
- data/src/ruby/ext/grpc/rb_channel_args.c +2 -2
- data/src/ruby/ext/grpc/rb_channel_credentials.c +4 -4
- data/src/ruby/ext/grpc/rb_channel_credentials.h +1 -0
- data/src/ruby/ext/grpc/rb_completion_queue.c +3 -2
- data/src/ruby/ext/grpc/rb_compression_options.c +5 -4
- data/src/ruby/ext/grpc/rb_event_thread.c +4 -4
- data/src/ruby/ext/grpc/rb_grpc.c +5 -4
- data/src/ruby/ext/grpc/rb_grpc.h +1 -0
- data/src/ruby/ext/grpc/rb_server.c +6 -5
- data/src/ruby/ext/grpc/rb_server_credentials.c +3 -3
- data/src/ruby/ext/grpc/rb_server_credentials.h +1 -0
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +8 -5
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.h +3 -1
- data/src/ruby/ext/grpc/rb_xds_server_credentials.c +6 -5
- data/src/ruby/ext/grpc/rb_xds_server_credentials.h +3 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/boringssl-with-bazel/err_data.c +294 -292
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +52 -47
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utf8.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/{asn1_locl.h → internal.h} +20 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_new.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_utl.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/time_support.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/conf/conf.c +14 -3
- data/third_party/boringssl-with-bazel/src/crypto/digest_extra/digest_extra.c +5 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.c +5 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +5 -9
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +4 -6
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +34 -0
- data/third_party/boringssl-with-bazel/src/crypto/hrss/hrss.c +219 -121
- data/third_party/boringssl-with-bazel/src/crypto/hrss/internal.h +9 -2
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +23 -2
- data/third_party/boringssl-with-bazel/src/crypto/lhash/internal.h +253 -0
- data/third_party/boringssl-with-bazel/src/crypto/lhash/lhash.c +28 -23
- data/third_party/boringssl-with-bazel/src/crypto/mem.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +7 -3
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/pool/pool.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/deterministic.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/fuchsia.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/windows.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_verify.c +15 -11
- data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/by_dir.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +45 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/rsa_pss.c +4 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +10 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +6 -23
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_lu.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +25 -22
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +0 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c +1 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +9 -11
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_exten.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +1 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +1 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_crld.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +14 -11
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -5
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +160 -74
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +0 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/conf.h +8 -5
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +3 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +6 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +25 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/hrss.h +14 -12
- data/third_party/boringssl-with-bazel/src/include/openssl/lhash.h +4 -205
- data/third_party/boringssl-with-bazel/src/include/openssl/mem.h +3 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/obj.h +5 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +58 -6
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +184 -55
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +0 -5
- data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +9 -16
- data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +44 -2
- data/third_party/boringssl-with-bazel/src/ssl/{t1_lib.cc → extensions.cc} +24 -11
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +9 -0
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +75 -68
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +17 -9
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +25 -6
- data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +1 -2
- data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +11 -5
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +0 -49
- data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +121 -65
- data/third_party/boringssl-with-bazel/src/ssl/ssl_x509.cc +14 -6
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +9 -11
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +2 -2
- data/third_party/upb/upb/decode.c +129 -60
- data/third_party/upb/upb/decode.h +32 -4
- data/third_party/upb/upb/decode_fast.c +513 -500
- data/third_party/upb/upb/decode_fast.h +27 -0
- data/third_party/upb/upb/{decode.int.h → decode_internal.h} +38 -8
- data/third_party/upb/upb/def.c +171 -181
- data/third_party/upb/upb/def.h +41 -19
- data/third_party/upb/upb/def.hpp +29 -0
- data/third_party/upb/upb/encode.c +49 -16
- data/third_party/upb/upb/encode.h +29 -2
- data/third_party/upb/upb/msg.c +169 -28
- data/third_party/upb/upb/msg.h +75 -580
- data/third_party/upb/upb/msg_internal.h +687 -0
- data/third_party/upb/upb/port_def.inc +85 -24
- data/third_party/upb/upb/port_undef.inc +38 -1
- data/third_party/upb/upb/reflection.c +29 -37
- data/third_party/upb/upb/reflection.h +36 -8
- data/third_party/upb/upb/reflection.hpp +37 -0
- data/third_party/upb/upb/table.c +211 -86
- data/third_party/upb/upb/{table.int.h → table_internal.h} +56 -180
- data/third_party/upb/upb/text_encode.c +32 -4
- data/third_party/upb/upb/text_encode.h +26 -0
- data/third_party/upb/upb/upb.c +59 -8
- data/third_party/upb/upb/upb.h +36 -6
- data/third_party/upb/upb/upb.hpp +24 -0
- data/third_party/upb/upb/upb_internal.h +58 -0
- data/third_party/xxhash/xxhash.h +77 -195
- metadata +79 -60
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +0 -179
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +0 -38
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +0 -243
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +0 -148
- data/src/core/lib/event_engine/slice_allocator.cc +0 -89
- data/src/core/lib/gpr/arena.h +0 -47
- data/src/core/lib/gpr/tls_gcc.h +0 -52
- data/src/core/lib/gpr/tls_msvc.h +0 -54
- data/src/core/lib/gpr/tls_pthread.cc +0 -30
- data/src/core/lib/gpr/tls_pthread.h +0 -56
- data/src/core/lib/gpr/tls_stdcpp.h +0 -48
- data/src/core/lib/gprpp/atomic.h +0 -104
- data/src/core/lib/iomgr/endpoint_pair_uv.cc +0 -40
- data/src/core/lib/iomgr/iomgr_uv.cc +0 -43
- data/src/core/lib/iomgr/pollset_uv.cc +0 -95
- data/src/core/lib/iomgr/pollset_uv.h +0 -36
- data/src/core/lib/iomgr/sockaddr_custom.h +0 -54
- data/src/core/lib/iomgr/socket_utils_uv.cc +0 -49
- data/src/core/lib/iomgr/tcp_uv.cc +0 -421
- data/src/core/lib/iomgr/timer_uv.cc +0 -66
- data/third_party/upb/third_party/wyhash/wyhash.h +0 -145
- data/third_party/upb/upb/upb.int.h +0 -29
@@ -19,7 +19,6 @@
|
|
19
19
|
#include <grpc/support/port_platform.h>
|
20
20
|
|
21
21
|
#include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
|
22
|
-
#include "src/core/ext/transport/chttp2/transport/internal.h"
|
23
22
|
|
24
23
|
#include <assert.h>
|
25
24
|
#include <stddef.h>
|
@@ -32,217 +31,27 @@
|
|
32
31
|
#include <grpc/support/log.h>
|
33
32
|
|
34
33
|
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
|
34
|
+
#include "src/core/ext/transport/chttp2/transport/internal.h"
|
35
35
|
#include "src/core/lib/debug/stats.h"
|
36
36
|
#include "src/core/lib/gpr/string.h"
|
37
|
+
#include "src/core/lib/gprpp/match.h"
|
37
38
|
#include "src/core/lib/profiling/timers.h"
|
38
39
|
#include "src/core/lib/slice/slice_internal.h"
|
39
40
|
#include "src/core/lib/slice/slice_string_helpers.h"
|
40
41
|
#include "src/core/lib/surface/validate_metadata.h"
|
41
42
|
#include "src/core/lib/transport/http2_errors.h"
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
/* How parsing works:
|
56
|
-
|
57
|
-
The parser object keeps track of a function pointer which represents the
|
58
|
-
current parse state.
|
59
|
-
|
60
|
-
Each time new bytes are presented, we call into the current state, which
|
61
|
-
recursively parses until all bytes in the given chunk are exhausted.
|
62
|
-
|
63
|
-
The parse state that terminates then saves its function pointer to be the
|
64
|
-
current state so that it can resume when more bytes are available.
|
65
|
-
|
66
|
-
It's expected that most optimizing compilers will turn this code into
|
67
|
-
a set of indirect jumps, and so not waste stack space. */
|
68
|
-
|
69
|
-
/* forward declarations for parsing states */
|
70
|
-
static grpc_error_handle parse_begin(grpc_chttp2_hpack_parser* p,
|
71
|
-
const uint8_t* cur, const uint8_t* end);
|
72
|
-
static grpc_error_handle parse_error(grpc_chttp2_hpack_parser* p,
|
73
|
-
const uint8_t* cur, const uint8_t* end,
|
74
|
-
grpc_error_handle error);
|
75
|
-
static grpc_error_handle still_parse_error(grpc_chttp2_hpack_parser* p,
|
76
|
-
const uint8_t* cur,
|
77
|
-
const uint8_t* end);
|
78
|
-
static grpc_error_handle parse_illegal_op(grpc_chttp2_hpack_parser* p,
|
79
|
-
const uint8_t* cur,
|
80
|
-
const uint8_t* end);
|
81
|
-
|
82
|
-
static grpc_error_handle parse_string_prefix(grpc_chttp2_hpack_parser* p,
|
83
|
-
const uint8_t* cur,
|
84
|
-
const uint8_t* end);
|
85
|
-
static grpc_error_handle parse_key_string(grpc_chttp2_hpack_parser* p,
|
86
|
-
const uint8_t* cur,
|
87
|
-
const uint8_t* end);
|
88
|
-
static grpc_error_handle parse_value_string_with_indexed_key(
|
89
|
-
grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end);
|
90
|
-
static grpc_error_handle parse_value_string_with_literal_key(
|
91
|
-
grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end);
|
92
|
-
|
93
|
-
static grpc_error_handle parse_value0(grpc_chttp2_hpack_parser* p,
|
94
|
-
const uint8_t* cur, const uint8_t* end);
|
95
|
-
static grpc_error_handle parse_value1(grpc_chttp2_hpack_parser* p,
|
96
|
-
const uint8_t* cur, const uint8_t* end);
|
97
|
-
static grpc_error_handle parse_value2(grpc_chttp2_hpack_parser* p,
|
98
|
-
const uint8_t* cur, const uint8_t* end);
|
99
|
-
static grpc_error_handle parse_value3(grpc_chttp2_hpack_parser* p,
|
100
|
-
const uint8_t* cur, const uint8_t* end);
|
101
|
-
static grpc_error_handle parse_value4(grpc_chttp2_hpack_parser* p,
|
102
|
-
const uint8_t* cur, const uint8_t* end);
|
103
|
-
static grpc_error_handle parse_value5up(grpc_chttp2_hpack_parser* p,
|
104
|
-
const uint8_t* cur, const uint8_t* end);
|
105
|
-
|
106
|
-
static grpc_error_handle parse_indexed_field(grpc_chttp2_hpack_parser* p,
|
107
|
-
const uint8_t* cur,
|
108
|
-
const uint8_t* end);
|
109
|
-
static grpc_error_handle parse_indexed_field_x(grpc_chttp2_hpack_parser* p,
|
110
|
-
const uint8_t* cur,
|
111
|
-
const uint8_t* end);
|
112
|
-
static grpc_error_handle parse_lithdr_incidx(grpc_chttp2_hpack_parser* p,
|
113
|
-
const uint8_t* cur,
|
114
|
-
const uint8_t* end);
|
115
|
-
static grpc_error_handle parse_lithdr_incidx_x(grpc_chttp2_hpack_parser* p,
|
116
|
-
const uint8_t* cur,
|
117
|
-
const uint8_t* end);
|
118
|
-
static grpc_error_handle parse_lithdr_incidx_v(grpc_chttp2_hpack_parser* p,
|
119
|
-
const uint8_t* cur,
|
120
|
-
const uint8_t* end);
|
121
|
-
static grpc_error_handle parse_lithdr_notidx(grpc_chttp2_hpack_parser* p,
|
122
|
-
const uint8_t* cur,
|
123
|
-
const uint8_t* end);
|
124
|
-
static grpc_error_handle parse_lithdr_notidx_x(grpc_chttp2_hpack_parser* p,
|
125
|
-
const uint8_t* cur,
|
126
|
-
const uint8_t* end);
|
127
|
-
static grpc_error_handle parse_lithdr_notidx_v(grpc_chttp2_hpack_parser* p,
|
128
|
-
const uint8_t* cur,
|
129
|
-
const uint8_t* end);
|
130
|
-
static grpc_error_handle parse_lithdr_nvridx(grpc_chttp2_hpack_parser* p,
|
131
|
-
const uint8_t* cur,
|
132
|
-
const uint8_t* end);
|
133
|
-
static grpc_error_handle parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser* p,
|
134
|
-
const uint8_t* cur,
|
135
|
-
const uint8_t* end);
|
136
|
-
static grpc_error_handle parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser* p,
|
137
|
-
const uint8_t* cur,
|
138
|
-
const uint8_t* end);
|
139
|
-
static grpc_error_handle parse_max_tbl_size(grpc_chttp2_hpack_parser* p,
|
140
|
-
const uint8_t* cur,
|
141
|
-
const uint8_t* end);
|
142
|
-
static grpc_error_handle parse_max_tbl_size_x(grpc_chttp2_hpack_parser* p,
|
143
|
-
const uint8_t* cur,
|
144
|
-
const uint8_t* end);
|
145
|
-
|
146
|
-
/* we translate the first byte of a hpack field into one of these decoding
|
147
|
-
cases, then use a lookup table to jump directly to the appropriate parser.
|
148
|
-
|
149
|
-
_X => the integer index is all ones, meaning we need to do varint decoding
|
150
|
-
_V => the integer index is all zeros, meaning we need to decode an additional
|
151
|
-
string value */
|
152
|
-
typedef enum {
|
153
|
-
INDEXED_FIELD,
|
154
|
-
INDEXED_FIELD_X,
|
155
|
-
LITHDR_INCIDX,
|
156
|
-
LITHDR_INCIDX_X,
|
157
|
-
LITHDR_INCIDX_V,
|
158
|
-
LITHDR_NOTIDX,
|
159
|
-
LITHDR_NOTIDX_X,
|
160
|
-
LITHDR_NOTIDX_V,
|
161
|
-
LITHDR_NVRIDX,
|
162
|
-
LITHDR_NVRIDX_X,
|
163
|
-
LITHDR_NVRIDX_V,
|
164
|
-
MAX_TBL_SIZE,
|
165
|
-
MAX_TBL_SIZE_X,
|
166
|
-
ILLEGAL
|
167
|
-
} first_byte_type;
|
168
|
-
|
169
|
-
/* jump table of parse state functions -- order must match first_byte_type
|
170
|
-
above */
|
171
|
-
static const grpc_chttp2_hpack_parser_state first_byte_action[] = {
|
172
|
-
parse_indexed_field, parse_indexed_field_x, parse_lithdr_incidx,
|
173
|
-
parse_lithdr_incidx_x, parse_lithdr_incidx_v, parse_lithdr_notidx,
|
174
|
-
parse_lithdr_notidx_x, parse_lithdr_notidx_v, parse_lithdr_nvridx,
|
175
|
-
parse_lithdr_nvridx_x, parse_lithdr_nvridx_v, parse_max_tbl_size,
|
176
|
-
parse_max_tbl_size_x, parse_illegal_op};
|
177
|
-
|
178
|
-
/* indexes the first byte to a parse state function - generated by
|
179
|
-
gen_hpack_tables.c */
|
180
|
-
static const uint8_t first_byte_lut[256] = {
|
181
|
-
LITHDR_NOTIDX_V, LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX,
|
182
|
-
LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX,
|
183
|
-
LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX,
|
184
|
-
LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX_X,
|
185
|
-
LITHDR_NVRIDX_V, LITHDR_NVRIDX, LITHDR_NVRIDX, LITHDR_NVRIDX,
|
186
|
-
LITHDR_NVRIDX, LITHDR_NVRIDX, LITHDR_NVRIDX, LITHDR_NVRIDX,
|
187
|
-
LITHDR_NVRIDX, LITHDR_NVRIDX, LITHDR_NVRIDX, LITHDR_NVRIDX,
|
188
|
-
LITHDR_NVRIDX, LITHDR_NVRIDX, LITHDR_NVRIDX, LITHDR_NVRIDX_X,
|
189
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE,
|
190
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE,
|
191
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE,
|
192
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE,
|
193
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE,
|
194
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE,
|
195
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE,
|
196
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE_X,
|
197
|
-
LITHDR_INCIDX_V, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
198
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
199
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
200
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
201
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
202
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
203
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
204
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
205
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
206
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
207
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
208
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
209
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
210
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
211
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
212
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX_X,
|
213
|
-
ILLEGAL, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
214
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
215
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
216
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
217
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
218
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
219
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
220
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
221
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
222
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
223
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
224
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
225
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
226
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
227
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
228
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
229
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
230
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
231
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
232
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
233
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
234
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
235
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
236
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
237
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
238
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
239
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
240
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
241
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
242
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
243
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
244
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD_X,
|
245
|
-
};
|
44
|
+
#if __cplusplus > 201103L
|
45
|
+
#define GRPC_HPACK_CONSTEXPR_FN constexpr
|
46
|
+
#define GRPC_HPACK_CONSTEXPR_VALUE constexpr
|
47
|
+
#else
|
48
|
+
#define GRPC_HPACK_CONSTEXPR_FN
|
49
|
+
#define GRPC_HPACK_CONSTEXPR_VALUE const
|
50
|
+
#endif
|
51
|
+
|
52
|
+
namespace grpc_core {
|
53
|
+
|
54
|
+
DebugOnlyTraceFlag grpc_trace_chttp2_hpack_parser(false, "chttp2_hpack_parser");
|
246
55
|
|
247
56
|
/* state table for huffman decoding: given a state, gives an index/16 into
|
248
57
|
next_sub_tbl. Taking that index and adding the value of the nibble being
|
@@ -617,1080 +426,906 @@ static const int16_t emit_sub_tbl[249 * 16] = {
|
|
617
426
|
13, 22, 22, 22, 22, 256, 256, 256, 256,
|
618
427
|
};
|
619
428
|
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
};
|
640
|
-
|
641
|
-
static void GPR_ATTRIBUTE_NOINLINE on_hdr_log(grpc_mdelem md) {
|
642
|
-
char* k = grpc_slice_to_c_string(GRPC_MDKEY(md));
|
643
|
-
char* v = nullptr;
|
644
|
-
if (grpc_is_binary_header_internal(GRPC_MDKEY(md))) {
|
645
|
-
v = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX);
|
646
|
-
} else {
|
647
|
-
v = grpc_slice_to_c_string(GRPC_MDVALUE(md));
|
429
|
+
namespace {
|
430
|
+
// The alphabet used for base64 encoding binary metadata.
|
431
|
+
static constexpr char kBase64Alphabet[] =
|
432
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
433
|
+
|
434
|
+
// An inverted table: for each value in kBase64Alphabet, table contains the
|
435
|
+
// index with which it's stored, so we can quickly invert the encoding without
|
436
|
+
// any complicated runtime logic.
|
437
|
+
struct Base64InverseTable {
|
438
|
+
uint8_t table[256]{};
|
439
|
+
GRPC_HPACK_CONSTEXPR_FN Base64InverseTable() {
|
440
|
+
for (int i = 0; i < 256; i++) {
|
441
|
+
table[i] = 255;
|
442
|
+
}
|
443
|
+
for (const char* p = kBase64Alphabet; *p; p++) {
|
444
|
+
uint8_t idx = *p;
|
445
|
+
uint8_t ofs = p - kBase64Alphabet;
|
446
|
+
table[idx] = ofs;
|
447
|
+
}
|
648
448
|
}
|
649
|
-
|
650
|
-
GPR_INFO,
|
651
|
-
"Decode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d",
|
652
|
-
k, v, GRPC_MDELEM_IS_INTERNED(md), GRPC_MDELEM_STORAGE(md),
|
653
|
-
grpc_slice_is_interned(GRPC_MDKEY(md)),
|
654
|
-
grpc_slice_is_interned(GRPC_MDVALUE(md)));
|
655
|
-
gpr_free(k);
|
656
|
-
gpr_free(v);
|
657
|
-
}
|
449
|
+
};
|
658
450
|
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
451
|
+
static GRPC_HPACK_CONSTEXPR_VALUE Base64InverseTable kBase64InverseTable;
|
452
|
+
} // namespace
|
453
|
+
|
454
|
+
// Input tracks the current byte through the input data and provides it
|
455
|
+
// via a simple stream interface.
|
456
|
+
class HPackParser::Input {
|
457
|
+
public:
|
458
|
+
Input(grpc_slice_refcount* current_slice_refcount, const uint8_t* begin,
|
459
|
+
const uint8_t* end)
|
460
|
+
: current_slice_refcount_(current_slice_refcount),
|
461
|
+
begin_(begin),
|
462
|
+
end_(end),
|
463
|
+
frontier_(begin) {}
|
464
|
+
|
465
|
+
// If input is backed by a slice, retrieve its refcount. If not, return
|
466
|
+
// nullptr.
|
467
|
+
grpc_slice_refcount* slice_refcount() { return current_slice_refcount_; }
|
468
|
+
|
469
|
+
// Have we reached the end of input?
|
470
|
+
bool end_of_stream() const { return begin_ == end_; }
|
471
|
+
// How many bytes until end of input
|
472
|
+
size_t remaining() const { return end_ - begin_; }
|
473
|
+
// Current position, as a pointer
|
474
|
+
const uint8_t* cur_ptr() const { return begin_; }
|
475
|
+
// End position, as a pointer
|
476
|
+
const uint8_t* end_ptr() const { return end_; }
|
477
|
+
// Move read position forward by n, unchecked
|
478
|
+
void Advance(size_t n) { begin_ += n; }
|
479
|
+
|
480
|
+
// Retrieve the current character, or nullopt if end of stream
|
481
|
+
// Do not advance
|
482
|
+
absl::optional<uint8_t> peek() const {
|
483
|
+
if (end_of_stream()) {
|
484
|
+
return {};
|
485
|
+
}
|
486
|
+
return *begin_;
|
670
487
|
}
|
671
|
-
return p->on_header(p->on_header_user_data, md);
|
672
|
-
}
|
673
488
|
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
str->data.referenced = grpc_core::UnmanagedMemorySlice();
|
682
|
-
} else {
|
683
|
-
s = grpc_core::UnmanagedMemorySlice(str->data.copied.str,
|
684
|
-
str->data.copied.length);
|
489
|
+
// Retrieve and advance past the current character, or return nullopt if end
|
490
|
+
// of stream
|
491
|
+
absl::optional<uint8_t> Next() {
|
492
|
+
if (end_of_stream()) {
|
493
|
+
return UnexpectedEOF(absl::optional<uint8_t>());
|
494
|
+
}
|
495
|
+
return *begin_++;
|
685
496
|
}
|
686
|
-
str->data.copied.length = 0;
|
687
|
-
return s;
|
688
|
-
}
|
689
497
|
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
498
|
+
// Helper to parse a varint delta on top of value, return nullopt on failure
|
499
|
+
// (setting error)
|
500
|
+
absl::optional<uint32_t> ParseVarint(uint32_t value) {
|
501
|
+
// TODO(ctiller): break out a variant of this when we know there are at
|
502
|
+
// least 5 bytes in input_
|
503
|
+
auto cur = Next();
|
504
|
+
if (!cur) return {};
|
505
|
+
value += *cur & 0x7f;
|
506
|
+
if ((*cur & 0x80) == 0) return value;
|
507
|
+
|
508
|
+
cur = Next();
|
509
|
+
if (!cur) return {};
|
510
|
+
value += (*cur & 0x7f) << 7;
|
511
|
+
if ((*cur & 0x80) == 0) return value;
|
512
|
+
|
513
|
+
cur = Next();
|
514
|
+
if (!cur) return {};
|
515
|
+
value += (*cur & 0x7f) << 14;
|
516
|
+
if ((*cur & 0x80) == 0) return value;
|
517
|
+
|
518
|
+
cur = Next();
|
519
|
+
if (!cur) return {};
|
520
|
+
value += (*cur & 0x7f) << 21;
|
521
|
+
if ((*cur & 0x80) == 0) return value;
|
522
|
+
|
523
|
+
cur = Next();
|
524
|
+
if (!cur) return {};
|
525
|
+
uint32_t c = (*cur) & 0x7f;
|
526
|
+
// We might overflow here, so we need to be a little careful about the
|
527
|
+
// addition
|
528
|
+
if (c > 0xf) return ParseVarintOutOfRange(value, *cur);
|
529
|
+
const uint32_t add = c << 28;
|
530
|
+
if (add > 0xffffffffu - value) {
|
531
|
+
return ParseVarintOutOfRange(value, *cur);
|
532
|
+
}
|
533
|
+
value += add;
|
534
|
+
if ((*cur & 0x80) == 0) return value;
|
535
|
+
|
536
|
+
// Spec weirdness: we can add an infinite stream of 0x80 at the end of a
|
537
|
+
// varint and still end up with a correctly encoded varint.
|
538
|
+
do {
|
539
|
+
cur = Next();
|
540
|
+
if (!cur.has_value()) return {};
|
541
|
+
} while (*cur == 0x80);
|
542
|
+
|
543
|
+
// BUT... the last byte needs to be 0x00 or we'll overflow dramatically!
|
544
|
+
if (*cur == 0) return value;
|
545
|
+
return ParseVarintOutOfRange(value, *cur);
|
701
546
|
}
|
702
|
-
str->data.copied.length = 0;
|
703
|
-
return s;
|
704
|
-
}
|
705
|
-
|
706
|
-
/* jump to the next state */
|
707
|
-
static grpc_error_handle parse_next(grpc_chttp2_hpack_parser* p,
|
708
|
-
const uint8_t* cur, const uint8_t* end) {
|
709
|
-
p->state = *p->next_state++;
|
710
|
-
return p->state(p, cur, end);
|
711
|
-
}
|
712
547
|
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
548
|
+
// Prefix for a string
|
549
|
+
struct StringPrefix {
|
550
|
+
// Number of bytes in input for string
|
551
|
+
uint32_t length;
|
552
|
+
// Is it huffman compressed
|
553
|
+
bool huff;
|
554
|
+
};
|
555
|
+
|
556
|
+
// Parse a string prefix
|
557
|
+
absl::optional<StringPrefix> ParseStringPrefix() {
|
558
|
+
auto cur = Next();
|
559
|
+
if (!cur.has_value()) return {};
|
560
|
+
// Huffman if the top bit is 1
|
561
|
+
const bool huff = (*cur & 0x80) != 0;
|
562
|
+
// String length
|
563
|
+
uint32_t strlen = (*cur & 0x7f);
|
564
|
+
if (strlen == 0x7f) {
|
565
|
+
// all ones ==> varint string length
|
566
|
+
auto v = ParseVarint(0x7f);
|
567
|
+
if (!v.has_value()) return {};
|
568
|
+
strlen = *v;
|
569
|
+
}
|
570
|
+
return StringPrefix{strlen, huff};
|
720
571
|
}
|
721
572
|
|
722
|
-
|
723
|
-
}
|
573
|
+
// Check if we saw an EOF.. must be verified before looking at TakeError
|
574
|
+
bool eof_error() const { return eof_error_; }
|
724
575
|
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
p->state = parse_stream_weight;
|
731
|
-
return GRPC_ERROR_NONE;
|
576
|
+
// Extract the parse error, leaving the current error as NONE.
|
577
|
+
grpc_error_handle TakeError() {
|
578
|
+
grpc_error_handle out = error_;
|
579
|
+
error_ = GRPC_ERROR_NONE;
|
580
|
+
return out;
|
732
581
|
}
|
733
582
|
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
583
|
+
// Set the current error - allows the rest of the code not to need to pass
|
584
|
+
// around StatusOr<> which would be prohibitive here.
|
585
|
+
GPR_ATTRIBUTE_NOINLINE void SetError(grpc_error_handle error) {
|
586
|
+
if (error_ != GRPC_ERROR_NONE || eof_error_) {
|
587
|
+
GRPC_ERROR_UNREF(error);
|
588
|
+
return;
|
589
|
+
}
|
590
|
+
error_ = error;
|
591
|
+
begin_ = end_;
|
743
592
|
}
|
744
593
|
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
return
|
594
|
+
// If no error is set, set it to the value produced by error_factory.
|
595
|
+
// Return return_value unchanged.
|
596
|
+
template <typename F, typename T>
|
597
|
+
GPR_ATTRIBUTE_NOINLINE T MaybeSetErrorAndReturn(F error_factory,
|
598
|
+
T return_value) {
|
599
|
+
if (error_ != GRPC_ERROR_NONE || eof_error_) return return_value;
|
600
|
+
error_ = error_factory();
|
601
|
+
begin_ = end_;
|
602
|
+
return return_value;
|
754
603
|
}
|
755
604
|
|
756
|
-
return
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
p->state = parse_stream_dep1;
|
764
|
-
return GRPC_ERROR_NONE;
|
605
|
+
// Set the error to an unexpected eof, and return result (code golfed as this
|
606
|
+
// is a common case)
|
607
|
+
template <typename T>
|
608
|
+
T UnexpectedEOF(T return_value) {
|
609
|
+
if (error_ != GRPC_ERROR_NONE) return return_value;
|
610
|
+
eof_error_ = true;
|
611
|
+
return return_value;
|
765
612
|
}
|
766
613
|
|
767
|
-
|
768
|
-
}
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
614
|
+
// Update the frontier - signifies we've successfully parsed another element
|
615
|
+
void UpdateFrontier() { frontier_ = begin_; }
|
616
|
+
|
617
|
+
// Get the frontier - for buffering should we fail due to eof
|
618
|
+
const uint8_t* frontier() const { return frontier_; }
|
619
|
+
|
620
|
+
private:
|
621
|
+
// Helper to set the error to out of range for ParseVarint
|
622
|
+
absl::optional<uint32_t> ParseVarintOutOfRange(uint32_t value,
|
623
|
+
uint8_t last_byte) {
|
624
|
+
return MaybeSetErrorAndReturn(
|
625
|
+
[value, last_byte] {
|
626
|
+
return GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrFormat(
|
627
|
+
"integer overflow in hpack integer decoding: have 0x%08x, "
|
628
|
+
"got byte 0x%02x on byte 5",
|
629
|
+
value, last_byte));
|
630
|
+
},
|
631
|
+
absl::optional<uint32_t>());
|
776
632
|
}
|
777
633
|
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
634
|
+
// Refcount if we are backed by a slice
|
635
|
+
grpc_slice_refcount* current_slice_refcount_;
|
636
|
+
// Current input point
|
637
|
+
const uint8_t* begin_;
|
638
|
+
// End of stream point
|
639
|
+
const uint8_t* const end_;
|
640
|
+
// Frontier denotes the first byte past successfully processed input
|
641
|
+
const uint8_t* frontier_;
|
642
|
+
// Current error
|
643
|
+
grpc_error_handle error_ = GRPC_ERROR_NONE;
|
644
|
+
// If the error was EOF, we flag it here..
|
645
|
+
bool eof_error_ = false;
|
646
|
+
};
|
789
647
|
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
648
|
+
// Helper to parse a string and turn it into a slice with appropriate memory
|
649
|
+
// management characteristics
|
650
|
+
class HPackParser::String {
|
651
|
+
public:
|
652
|
+
// Helper to specify a string should be internalized
|
653
|
+
struct Intern {};
|
654
|
+
// Helper to specify a string should be externalized
|
655
|
+
struct Extern {};
|
656
|
+
|
657
|
+
private:
|
658
|
+
// Forward declare take functions... we'll need them in the public interface
|
659
|
+
UnmanagedMemorySlice Take(Extern);
|
660
|
+
ManagedMemorySlice Take(Intern);
|
661
|
+
|
662
|
+
public:
|
663
|
+
// If a String is a Slice then unref
|
664
|
+
~String() {
|
665
|
+
if (auto* p = absl::get_if<grpc_slice>(&value_)) {
|
666
|
+
grpc_slice_unref_internal(*p);
|
667
|
+
}
|
797
668
|
}
|
798
|
-
GRPC_STATS_INC_HPACK_RECV_INDEXED();
|
799
|
-
grpc_error_handle err = on_hdr<false>(p, md);
|
800
|
-
if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) return err;
|
801
|
-
return parse_begin(p, cur, end);
|
802
|
-
}
|
803
|
-
|
804
|
-
/* parse an indexed field with index < 127 */
|
805
|
-
static grpc_error_handle parse_indexed_field(grpc_chttp2_hpack_parser* p,
|
806
|
-
const uint8_t* cur,
|
807
|
-
const uint8_t* end) {
|
808
|
-
p->dynamic_table_update_allowed = 0;
|
809
|
-
p->index = (*cur) & 0x7f;
|
810
|
-
p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */
|
811
|
-
return finish_indexed_field(p, cur + 1, end);
|
812
|
-
}
|
813
|
-
|
814
|
-
/* parse an indexed field with index >= 127 */
|
815
|
-
static grpc_error_handle parse_indexed_field_x(grpc_chttp2_hpack_parser* p,
|
816
|
-
const uint8_t* cur,
|
817
|
-
const uint8_t* end) {
|
818
|
-
static const grpc_chttp2_hpack_parser_state and_then[] = {
|
819
|
-
finish_indexed_field};
|
820
|
-
p->dynamic_table_update_allowed = 0;
|
821
|
-
p->next_state = and_then;
|
822
|
-
p->index = 0x7f;
|
823
|
-
p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */
|
824
|
-
p->parsing.value = &p->index;
|
825
|
-
return parse_value0(p, cur + 1, end);
|
826
|
-
}
|
827
|
-
|
828
|
-
/* When finishing with a header, get the cached md element for this index.
|
829
|
-
This is set in parse_value_string(). We ensure (in debug mode) that the
|
830
|
-
cached metadata corresponds with the index we are examining. */
|
831
|
-
static grpc_mdelem get_precomputed_md_for_idx(grpc_chttp2_hpack_parser* p) {
|
832
|
-
GPR_DEBUG_ASSERT(p->md_for_index.payload != 0);
|
833
|
-
GPR_DEBUG_ASSERT(static_cast<int64_t>(p->index) == p->precomputed_md_index);
|
834
|
-
grpc_mdelem md = p->md_for_index;
|
835
|
-
GPR_DEBUG_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */
|
836
|
-
p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */
|
837
|
-
#ifndef NDEBUG
|
838
|
-
p->precomputed_md_index = -1;
|
839
|
-
#endif
|
840
|
-
return md;
|
841
|
-
}
|
842
|
-
|
843
|
-
static const grpc_core::ManagedMemorySlice& get_indexed_key(grpc_mdelem md) {
|
844
|
-
GPR_DEBUG_ASSERT(GRPC_MDELEM_IS_INTERNED(md));
|
845
|
-
return static_cast<const grpc_core::ManagedMemorySlice&>(
|
846
|
-
grpc_slice_ref_internal(GRPC_MDKEY(md)));
|
847
|
-
}
|
848
|
-
|
849
|
-
/* finish a literal header with incremental indexing */
|
850
|
-
static grpc_error_handle finish_lithdr_incidx(grpc_chttp2_hpack_parser* p,
|
851
|
-
const uint8_t* cur,
|
852
|
-
const uint8_t* end) {
|
853
|
-
GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX();
|
854
|
-
grpc_mdelem md = get_precomputed_md_for_idx(p);
|
855
|
-
grpc_error_handle err = on_hdr<true>(
|
856
|
-
p, grpc_mdelem_from_slices(get_indexed_key(md),
|
857
|
-
take_string_intern(p, &p->value)));
|
858
|
-
if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
|
859
|
-
return parse_begin(p, cur, end);
|
860
|
-
}
|
861
|
-
|
862
|
-
/* finish a literal header with incremental indexing with no index */
|
863
|
-
static grpc_error_handle finish_lithdr_incidx_v(grpc_chttp2_hpack_parser* p,
|
864
|
-
const uint8_t* cur,
|
865
|
-
const uint8_t* end) {
|
866
|
-
GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V();
|
867
|
-
grpc_error_handle err = on_hdr<true>(
|
868
|
-
p, grpc_mdelem_from_slices(take_string_intern(p, &p->key),
|
869
|
-
take_string_intern(p, &p->value)));
|
870
|
-
if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
|
871
|
-
return parse_begin(p, cur, end);
|
872
|
-
}
|
873
669
|
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
parse_value_string_with_indexed_key, finish_lithdr_incidx};
|
880
|
-
p->dynamic_table_update_allowed = 0;
|
881
|
-
p->next_state = and_then;
|
882
|
-
p->index = (*cur) & 0x3f;
|
883
|
-
p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */
|
884
|
-
return parse_string_prefix(p, cur + 1, end);
|
885
|
-
}
|
886
|
-
|
887
|
-
/* parse a literal header with incremental indexing; index >= 63 */
|
888
|
-
static grpc_error_handle parse_lithdr_incidx_x(grpc_chttp2_hpack_parser* p,
|
889
|
-
const uint8_t* cur,
|
890
|
-
const uint8_t* end) {
|
891
|
-
static const grpc_chttp2_hpack_parser_state and_then[] = {
|
892
|
-
parse_string_prefix, parse_value_string_with_indexed_key,
|
893
|
-
finish_lithdr_incidx};
|
894
|
-
p->dynamic_table_update_allowed = 0;
|
895
|
-
p->next_state = and_then;
|
896
|
-
p->index = 0x3f;
|
897
|
-
p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */
|
898
|
-
p->parsing.value = &p->index;
|
899
|
-
return parse_value0(p, cur + 1, end);
|
900
|
-
}
|
901
|
-
|
902
|
-
/* parse a literal header with incremental indexing; index = 0 */
|
903
|
-
static grpc_error_handle parse_lithdr_incidx_v(grpc_chttp2_hpack_parser* p,
|
904
|
-
const uint8_t* cur,
|
905
|
-
const uint8_t* end) {
|
906
|
-
static const grpc_chttp2_hpack_parser_state and_then[] = {
|
907
|
-
parse_key_string, parse_string_prefix,
|
908
|
-
parse_value_string_with_literal_key, finish_lithdr_incidx_v};
|
909
|
-
p->dynamic_table_update_allowed = 0;
|
910
|
-
p->next_state = and_then;
|
911
|
-
return parse_string_prefix(p, cur + 1, end);
|
912
|
-
}
|
913
|
-
|
914
|
-
/* finish a literal header without incremental indexing */
|
915
|
-
static grpc_error_handle finish_lithdr_notidx(grpc_chttp2_hpack_parser* p,
|
916
|
-
const uint8_t* cur,
|
917
|
-
const uint8_t* end) {
|
918
|
-
GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX();
|
919
|
-
grpc_mdelem md = get_precomputed_md_for_idx(p);
|
920
|
-
grpc_error_handle err = on_hdr<false>(
|
921
|
-
p, grpc_mdelem_from_slices(get_indexed_key(md),
|
922
|
-
take_string_extern(p, &p->value)));
|
923
|
-
if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
|
924
|
-
return parse_begin(p, cur, end);
|
925
|
-
}
|
926
|
-
|
927
|
-
/* finish a literal header without incremental indexing with index = 0 */
|
928
|
-
static grpc_error_handle finish_lithdr_notidx_v(grpc_chttp2_hpack_parser* p,
|
929
|
-
const uint8_t* cur,
|
930
|
-
const uint8_t* end) {
|
931
|
-
GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V();
|
932
|
-
grpc_error_handle err = on_hdr<false>(
|
933
|
-
p, grpc_mdelem_from_slices(take_string_intern(p, &p->key),
|
934
|
-
take_string_extern(p, &p->value)));
|
935
|
-
if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
|
936
|
-
return parse_begin(p, cur, end);
|
937
|
-
}
|
938
|
-
|
939
|
-
/* parse a literal header without incremental indexing; index < 15 */
|
940
|
-
static grpc_error_handle parse_lithdr_notidx(grpc_chttp2_hpack_parser* p,
|
941
|
-
const uint8_t* cur,
|
942
|
-
const uint8_t* end) {
|
943
|
-
static const grpc_chttp2_hpack_parser_state and_then[] = {
|
944
|
-
parse_value_string_with_indexed_key, finish_lithdr_notidx};
|
945
|
-
p->dynamic_table_update_allowed = 0;
|
946
|
-
p->next_state = and_then;
|
947
|
-
p->index = (*cur) & 0xf;
|
948
|
-
p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */
|
949
|
-
return parse_string_prefix(p, cur + 1, end);
|
950
|
-
}
|
951
|
-
|
952
|
-
/* parse a literal header without incremental indexing; index >= 15 */
|
953
|
-
static grpc_error_handle parse_lithdr_notidx_x(grpc_chttp2_hpack_parser* p,
|
954
|
-
const uint8_t* cur,
|
955
|
-
const uint8_t* end) {
|
956
|
-
static const grpc_chttp2_hpack_parser_state and_then[] = {
|
957
|
-
parse_string_prefix, parse_value_string_with_indexed_key,
|
958
|
-
finish_lithdr_notidx};
|
959
|
-
p->dynamic_table_update_allowed = 0;
|
960
|
-
p->next_state = and_then;
|
961
|
-
p->index = 0xf;
|
962
|
-
p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */
|
963
|
-
p->parsing.value = &p->index;
|
964
|
-
return parse_value0(p, cur + 1, end);
|
965
|
-
}
|
966
|
-
|
967
|
-
/* parse a literal header without incremental indexing; index == 0 */
|
968
|
-
static grpc_error_handle parse_lithdr_notidx_v(grpc_chttp2_hpack_parser* p,
|
969
|
-
const uint8_t* cur,
|
970
|
-
const uint8_t* end) {
|
971
|
-
static const grpc_chttp2_hpack_parser_state and_then[] = {
|
972
|
-
parse_key_string, parse_string_prefix,
|
973
|
-
parse_value_string_with_literal_key, finish_lithdr_notidx_v};
|
974
|
-
p->dynamic_table_update_allowed = 0;
|
975
|
-
p->next_state = and_then;
|
976
|
-
return parse_string_prefix(p, cur + 1, end);
|
977
|
-
}
|
978
|
-
|
979
|
-
/* finish a literal header that is never indexed */
|
980
|
-
static grpc_error_handle finish_lithdr_nvridx(grpc_chttp2_hpack_parser* p,
|
981
|
-
const uint8_t* cur,
|
982
|
-
const uint8_t* end) {
|
983
|
-
GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX();
|
984
|
-
grpc_mdelem md = get_precomputed_md_for_idx(p);
|
985
|
-
grpc_error_handle err = on_hdr<false>(
|
986
|
-
p, grpc_mdelem_from_slices(get_indexed_key(md),
|
987
|
-
take_string_extern(p, &p->value)));
|
988
|
-
if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
|
989
|
-
return parse_begin(p, cur, end);
|
990
|
-
}
|
991
|
-
|
992
|
-
/* finish a literal header that is never indexed with an extra value */
|
993
|
-
static grpc_error_handle finish_lithdr_nvridx_v(grpc_chttp2_hpack_parser* p,
|
994
|
-
const uint8_t* cur,
|
995
|
-
const uint8_t* end) {
|
996
|
-
GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V();
|
997
|
-
grpc_error_handle err = on_hdr<false>(
|
998
|
-
p, grpc_mdelem_from_slices(take_string_intern(p, &p->key),
|
999
|
-
take_string_extern(p, &p->value)));
|
1000
|
-
if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
|
1001
|
-
return parse_begin(p, cur, end);
|
1002
|
-
}
|
1003
|
-
|
1004
|
-
/* parse a literal header that is never indexed; index < 15 */
|
1005
|
-
static grpc_error_handle parse_lithdr_nvridx(grpc_chttp2_hpack_parser* p,
|
1006
|
-
const uint8_t* cur,
|
1007
|
-
const uint8_t* end) {
|
1008
|
-
static const grpc_chttp2_hpack_parser_state and_then[] = {
|
1009
|
-
parse_value_string_with_indexed_key, finish_lithdr_nvridx};
|
1010
|
-
p->dynamic_table_update_allowed = 0;
|
1011
|
-
p->next_state = and_then;
|
1012
|
-
p->index = (*cur) & 0xf;
|
1013
|
-
p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */
|
1014
|
-
return parse_string_prefix(p, cur + 1, end);
|
1015
|
-
}
|
1016
|
-
|
1017
|
-
/* parse a literal header that is never indexed; index >= 15 */
|
1018
|
-
static grpc_error_handle parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser* p,
|
1019
|
-
const uint8_t* cur,
|
1020
|
-
const uint8_t* end) {
|
1021
|
-
static const grpc_chttp2_hpack_parser_state and_then[] = {
|
1022
|
-
parse_string_prefix, parse_value_string_with_indexed_key,
|
1023
|
-
finish_lithdr_nvridx};
|
1024
|
-
p->dynamic_table_update_allowed = 0;
|
1025
|
-
p->next_state = and_then;
|
1026
|
-
p->index = 0xf;
|
1027
|
-
p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */
|
1028
|
-
p->parsing.value = &p->index;
|
1029
|
-
return parse_value0(p, cur + 1, end);
|
1030
|
-
}
|
1031
|
-
|
1032
|
-
/* parse a literal header that is never indexed; index == 0 */
|
1033
|
-
static grpc_error_handle parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser* p,
|
1034
|
-
const uint8_t* cur,
|
1035
|
-
const uint8_t* end) {
|
1036
|
-
static const grpc_chttp2_hpack_parser_state and_then[] = {
|
1037
|
-
parse_key_string, parse_string_prefix,
|
1038
|
-
parse_value_string_with_literal_key, finish_lithdr_nvridx_v};
|
1039
|
-
p->dynamic_table_update_allowed = 0;
|
1040
|
-
p->next_state = and_then;
|
1041
|
-
return parse_string_prefix(p, cur + 1, end);
|
1042
|
-
}
|
1043
|
-
|
1044
|
-
/* finish parsing a max table size change */
|
1045
|
-
static grpc_error_handle finish_max_tbl_size(grpc_chttp2_hpack_parser* p,
|
1046
|
-
const uint8_t* cur,
|
1047
|
-
const uint8_t* end) {
|
1048
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) {
|
1049
|
-
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", p->index);
|
670
|
+
// Take the value and leave this empty
|
671
|
+
// Use Intern/Extern to choose memory management
|
672
|
+
template <typename T>
|
673
|
+
auto Take() -> decltype(this->Take(T())) {
|
674
|
+
return Take(T());
|
1050
675
|
}
|
1051
|
-
grpc_error_handle err =
|
1052
|
-
grpc_chttp2_hptbl_set_current_table_size(&p->table, p->index);
|
1053
|
-
if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
|
1054
|
-
return parse_begin(p, cur, end);
|
1055
|
-
}
|
1056
676
|
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
if (p->dynamic_table_update_allowed == 0) {
|
1062
|
-
return parse_error(
|
1063
|
-
p, cur, end,
|
1064
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1065
|
-
"More than two max table size changes in a single frame"));
|
677
|
+
String(const String&) = delete;
|
678
|
+
String& operator=(const String&) = delete;
|
679
|
+
String(String&& other) noexcept : value_(std::move(other.value_)) {
|
680
|
+
other.value_ = absl::Span<const uint8_t>();
|
1066
681
|
}
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
}
|
1072
|
-
|
1073
|
-
/* parse a max table size change, max size >= 15 */
|
1074
|
-
static grpc_error_handle parse_max_tbl_size_x(grpc_chttp2_hpack_parser* p,
|
1075
|
-
const uint8_t* cur,
|
1076
|
-
const uint8_t* end) {
|
1077
|
-
static const grpc_chttp2_hpack_parser_state and_then[] = {
|
1078
|
-
finish_max_tbl_size};
|
1079
|
-
if (p->dynamic_table_update_allowed == 0) {
|
1080
|
-
return parse_error(
|
1081
|
-
p, cur, end,
|
1082
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1083
|
-
"More than two max table size changes in a single frame"));
|
682
|
+
String& operator=(String&& other) noexcept {
|
683
|
+
value_ = std::move(other.value_);
|
684
|
+
other.value_ = absl::Span<const uint8_t>();
|
685
|
+
return *this;
|
1084
686
|
}
|
1085
|
-
p->dynamic_table_update_allowed--;
|
1086
|
-
p->next_state = and_then;
|
1087
|
-
p->index = 0x1f;
|
1088
|
-
p->md_for_index.payload = 0; /* Invalidate cached md when index changes. */
|
1089
|
-
p->parsing.value = &p->index;
|
1090
|
-
return parse_value0(p, cur + 1, end);
|
1091
|
-
}
|
1092
687
|
|
1093
|
-
|
1094
|
-
static
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
688
|
+
// Parse a non-binary string
|
689
|
+
static absl::optional<String> Parse(Input* input) {
|
690
|
+
auto pfx = input->ParseStringPrefix();
|
691
|
+
if (!pfx.has_value()) return {};
|
692
|
+
if (pfx->huff) {
|
693
|
+
// Huffman coded
|
694
|
+
std::vector<uint8_t> output;
|
695
|
+
auto v = ParseHuff(input, pfx->length,
|
696
|
+
[&output](uint8_t c) { output.push_back(c); });
|
697
|
+
if (!v) return {};
|
698
|
+
return String(std::move(output));
|
699
|
+
}
|
700
|
+
return ParseUncompressed(input, pfx->length);
|
1101
701
|
}
|
1102
|
-
p->state = still_parse_error;
|
1103
|
-
return err;
|
1104
|
-
}
|
1105
|
-
|
1106
|
-
static grpc_error_handle still_parse_error(grpc_chttp2_hpack_parser* p,
|
1107
|
-
const uint8_t* /*cur*/,
|
1108
|
-
const uint8_t* /*end*/) {
|
1109
|
-
return GRPC_ERROR_REF(p->last_error);
|
1110
|
-
}
|
1111
702
|
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
703
|
+
// Parse a binary string
|
704
|
+
static absl::optional<String> ParseBinary(Input* input) {
|
705
|
+
auto pfx = input->ParseStringPrefix();
|
706
|
+
if (!pfx.has_value()) return {};
|
707
|
+
if (!pfx->huff) {
|
708
|
+
if (pfx->length > 0 && input->peek() == 0) {
|
709
|
+
// 'true-binary'
|
710
|
+
input->Advance(1);
|
711
|
+
return ParseUncompressed(input, pfx->length - 1);
|
712
|
+
}
|
713
|
+
// Base64 encoded... pull out the string, then unbase64 it
|
714
|
+
auto base64 = ParseUncompressed(input, pfx->length);
|
715
|
+
if (!base64.has_value()) return {};
|
716
|
+
return Unbase64(input, std::move(*base64));
|
717
|
+
} else {
|
718
|
+
// Huffman encoded...
|
719
|
+
std::vector<uint8_t> decompressed;
|
720
|
+
// State here says either we don't know if it's base64 or binary, or we do
|
721
|
+
// and what is it.
|
722
|
+
enum class State { kUnsure, kBinary, kBase64 };
|
723
|
+
State state = State::kUnsure;
|
724
|
+
auto decompressed_ok =
|
725
|
+
ParseHuff(input, pfx->length, [&state, &decompressed](uint8_t c) {
|
726
|
+
if (state == State::kUnsure) {
|
727
|
+
// First byte... if it's zero it's binary
|
728
|
+
if (c == 0) {
|
729
|
+
// Save the type, and skip the zero
|
730
|
+
state = State::kBinary;
|
731
|
+
return;
|
732
|
+
} else {
|
733
|
+
// Flag base64, store this value
|
734
|
+
state = State::kBase64;
|
735
|
+
}
|
736
|
+
}
|
737
|
+
// Non-first byte, or base64 first byte
|
738
|
+
decompressed.push_back(c);
|
739
|
+
});
|
740
|
+
if (!decompressed_ok) return {};
|
741
|
+
switch (state) {
|
742
|
+
case State::kUnsure:
|
743
|
+
// No bytes, empty span
|
744
|
+
return String(absl::Span<const uint8_t>());
|
745
|
+
case State::kBinary:
|
746
|
+
// Binary, we're done
|
747
|
+
return String(std::move(decompressed));
|
748
|
+
case State::kBase64:
|
749
|
+
// Base64 - unpack it
|
750
|
+
return Unbase64(input, String(std::move(decompressed)));
|
751
|
+
}
|
752
|
+
GPR_UNREACHABLE_CODE(abort(););
|
753
|
+
}
|
1128
754
|
}
|
1129
755
|
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
756
|
+
private:
|
757
|
+
void AppendBytes(const uint8_t* data, size_t length);
|
758
|
+
explicit String(std::vector<uint8_t> v) : value_(std::move(v)) {}
|
759
|
+
explicit String(absl::Span<const uint8_t> v) : value_(v) {}
|
760
|
+
String(grpc_slice_refcount* r, const uint8_t* begin, const uint8_t* end)
|
761
|
+
: value_(MakeSlice(r, begin, end)) {}
|
762
|
+
|
763
|
+
// Given a refcount and a byte range, make a slice
|
764
|
+
static grpc_slice MakeSlice(grpc_slice_refcount* r, const uint8_t* begin,
|
765
|
+
const uint8_t* end) {
|
766
|
+
grpc_slice out;
|
767
|
+
out.refcount = r;
|
768
|
+
r->Ref();
|
769
|
+
out.data.refcounted.bytes = const_cast<uint8_t*>(begin);
|
770
|
+
out.data.refcounted.length = end - begin;
|
771
|
+
return out;
|
1136
772
|
}
|
1137
|
-
}
|
1138
773
|
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
774
|
+
// Parse some huffman encoded bytes, using output(uint8_t b) to emit each
|
775
|
+
// decoded byte.
|
776
|
+
template <typename Out>
|
777
|
+
static bool ParseHuff(Input* input, uint32_t length, Out output) {
|
778
|
+
GRPC_STATS_INC_HPACK_RECV_HUFFMAN();
|
779
|
+
int16_t state = 0;
|
780
|
+
// Parse one half byte... we leverage some lookup tables to keep the logic
|
781
|
+
// here really simple.
|
782
|
+
auto nibble = [&output, &state](uint8_t nibble) {
|
783
|
+
int16_t emit = emit_sub_tbl[16 * emit_tbl[state] + nibble];
|
784
|
+
int16_t next = next_sub_tbl[16 * next_tbl[state] + nibble];
|
785
|
+
if (emit != -1) {
|
786
|
+
if (emit >= 0 && emit < 256) {
|
787
|
+
output(static_cast<uint8_t>(emit));
|
788
|
+
} else {
|
789
|
+
assert(emit == 256);
|
790
|
+
}
|
791
|
+
}
|
792
|
+
state = next;
|
793
|
+
};
|
794
|
+
// If there's insufficient bytes remaining, return now.
|
795
|
+
if (input->remaining() < length) {
|
796
|
+
return input->UnexpectedEOF(false);
|
797
|
+
}
|
798
|
+
// Grab the byte range, and iterate through it.
|
799
|
+
const uint8_t* p = input->cur_ptr();
|
800
|
+
input->Advance(length);
|
801
|
+
for (uint32_t i = 0; i < length; i++) {
|
802
|
+
nibble(p[i] >> 4);
|
803
|
+
nibble(p[i] & 0xf);
|
804
|
+
}
|
805
|
+
return true;
|
1146
806
|
}
|
1147
807
|
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
808
|
+
// Parse some uncompressed string bytes.
|
809
|
+
static absl::optional<String> ParseUncompressed(Input* input,
|
810
|
+
uint32_t length) {
|
811
|
+
GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED();
|
812
|
+
// Check there's enough bytes
|
813
|
+
if (input->remaining() < length) {
|
814
|
+
return input->UnexpectedEOF(absl::optional<String>());
|
815
|
+
}
|
816
|
+
auto* refcount = input->slice_refcount();
|
817
|
+
auto* p = input->cur_ptr();
|
818
|
+
input->Advance(length);
|
819
|
+
if (refcount != nullptr) {
|
820
|
+
return String(refcount, p, p + length);
|
821
|
+
} else {
|
822
|
+
return String(absl::Span<const uint8_t>(p, length));
|
823
|
+
}
|
1154
824
|
}
|
1155
|
-
}
|
1156
825
|
|
1157
|
-
|
1158
|
-
|
1159
|
-
static
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
826
|
+
// Turn base64 encoded bytes into not base64 encoded bytes.
|
827
|
+
// Only takes input to set an error on failure.
|
828
|
+
static absl::optional<String> Unbase64(Input* input, String s) {
|
829
|
+
auto v = Match(
|
830
|
+
s.value_,
|
831
|
+
[](const grpc_slice& slice) {
|
832
|
+
return Unbase64Loop(GRPC_SLICE_START_PTR(slice),
|
833
|
+
GRPC_SLICE_END_PTR(slice));
|
834
|
+
},
|
835
|
+
[](absl::Span<const uint8_t> span) {
|
836
|
+
return Unbase64Loop(span.begin(), span.end());
|
837
|
+
},
|
838
|
+
[](const std::vector<uint8_t>& vec) {
|
839
|
+
return Unbase64Loop(vec.data(), vec.data() + vec.size());
|
840
|
+
});
|
841
|
+
if (!v.has_value()) {
|
842
|
+
return input->MaybeSetErrorAndReturn(
|
843
|
+
[] {
|
844
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
845
|
+
"illegal base64 encoding");
|
846
|
+
},
|
847
|
+
absl::optional<String>());
|
848
|
+
}
|
849
|
+
return String(std::move(*v));
|
1164
850
|
}
|
1165
851
|
|
1166
|
-
|
852
|
+
// Main loop for Unbase64
|
853
|
+
static absl::optional<std::vector<uint8_t>> Unbase64Loop(const uint8_t* cur,
|
854
|
+
const uint8_t* end) {
|
855
|
+
while (cur != end && end[-1] == '=') {
|
856
|
+
--end;
|
857
|
+
}
|
1167
858
|
|
1168
|
-
|
1169
|
-
|
1170
|
-
} else {
|
1171
|
-
return parse_next(p, cur + 1, end);
|
1172
|
-
}
|
1173
|
-
}
|
859
|
+
std::vector<uint8_t> out;
|
860
|
+
out.reserve(3 * (end - cur) / 4 + 3);
|
1174
861
|
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
return GRPC_ERROR_NONE;
|
1182
|
-
}
|
862
|
+
// Decode 4 bytes at a time while we can
|
863
|
+
while (end - cur >= 4) {
|
864
|
+
uint32_t bits = kBase64InverseTable.table[*cur];
|
865
|
+
if (bits > 63) return {};
|
866
|
+
uint32_t buffer = bits << 18;
|
867
|
+
++cur;
|
1183
868
|
|
1184
|
-
|
869
|
+
bits = kBase64InverseTable.table[*cur];
|
870
|
+
if (bits > 63) return {};
|
871
|
+
buffer |= bits << 12;
|
872
|
+
++cur;
|
1185
873
|
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
}
|
1191
|
-
}
|
874
|
+
bits = kBase64InverseTable.table[*cur];
|
875
|
+
if (bits > 63) return {};
|
876
|
+
buffer |= bits << 6;
|
877
|
+
++cur;
|
1192
878
|
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
uint8_t c;
|
1198
|
-
uint32_t cur_value;
|
1199
|
-
uint32_t add_value;
|
879
|
+
bits = kBase64InverseTable.table[*cur];
|
880
|
+
if (bits > 63) return {};
|
881
|
+
buffer |= bits;
|
882
|
+
++cur;
|
1200
883
|
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
884
|
+
out.insert(out.end(), {static_cast<uint8_t>(buffer >> 16),
|
885
|
+
static_cast<uint8_t>(buffer >> 8),
|
886
|
+
static_cast<uint8_t>(buffer)});
|
887
|
+
}
|
888
|
+
// Deal with the last 0, 1, 2, or 3 bytes.
|
889
|
+
switch (end - cur) {
|
890
|
+
case 0:
|
891
|
+
return out;
|
892
|
+
case 1:
|
893
|
+
return {};
|
894
|
+
case 2: {
|
895
|
+
uint32_t bits = kBase64InverseTable.table[*cur];
|
896
|
+
if (bits > 63) return {};
|
897
|
+
uint32_t buffer = bits << 18;
|
1205
898
|
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
899
|
+
++cur;
|
900
|
+
bits = kBase64InverseTable.table[*cur];
|
901
|
+
if (bits > 63) return {};
|
902
|
+
buffer |= bits << 12;
|
1210
903
|
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
904
|
+
if (buffer & 0xffff) return {};
|
905
|
+
out.push_back(static_cast<uint8_t>(buffer >> 16));
|
906
|
+
return out;
|
907
|
+
}
|
908
|
+
case 3: {
|
909
|
+
uint32_t bits = kBase64InverseTable.table[*cur];
|
910
|
+
if (bits > 63) return {};
|
911
|
+
uint32_t buffer = bits << 18;
|
1216
912
|
|
1217
|
-
|
913
|
+
++cur;
|
914
|
+
bits = kBase64InverseTable.table[*cur];
|
915
|
+
if (bits > 63) return {};
|
916
|
+
buffer |= bits << 12;
|
1218
917
|
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
}
|
918
|
+
++cur;
|
919
|
+
bits = kBase64InverseTable.table[*cur];
|
920
|
+
if (bits > 63) return {};
|
921
|
+
buffer |= bits << 6;
|
1224
922
|
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
return parse_error(p, cur, end, err);
|
1233
|
-
}
|
923
|
+
++cur;
|
924
|
+
if (buffer & 0xff) return {};
|
925
|
+
out.push_back(static_cast<uint8_t>(buffer >> 16));
|
926
|
+
out.push_back(static_cast<uint8_t>(buffer >> 8));
|
927
|
+
return out;
|
928
|
+
}
|
929
|
+
}
|
1234
930
|
|
1235
|
-
|
1236
|
-
number of 0x80's and not affect the value - a zero will terminate - and
|
1237
|
-
anything else will overflow */
|
1238
|
-
static grpc_error_handle parse_value5up(grpc_chttp2_hpack_parser* p,
|
1239
|
-
const uint8_t* cur,
|
1240
|
-
const uint8_t* end) {
|
1241
|
-
while (cur != end && *cur == 0x80) {
|
1242
|
-
++cur;
|
931
|
+
GPR_UNREACHABLE_CODE(return out;);
|
1243
932
|
}
|
1244
933
|
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
}
|
934
|
+
absl::variant<grpc_slice, absl::Span<const uint8_t>, std::vector<uint8_t>>
|
935
|
+
value_;
|
936
|
+
};
|
1249
937
|
|
1250
|
-
|
1251
|
-
|
938
|
+
// Parser parses one frame + continuations worth of headers.
|
939
|
+
class HPackParser::Parser {
|
940
|
+
public:
|
941
|
+
Parser(Input* input, HPackParser::Sink* sink, HPackTable* table,
|
942
|
+
uint8_t* dynamic_table_updates_allowed)
|
943
|
+
: input_(input),
|
944
|
+
sink_(sink),
|
945
|
+
table_(table),
|
946
|
+
dynamic_table_updates_allowed_(dynamic_table_updates_allowed) {}
|
947
|
+
|
948
|
+
// Skip any priority bits, or return false on failure
|
949
|
+
bool SkipPriority() {
|
950
|
+
if (input_->remaining() < 5) return input_->UnexpectedEOF(false);
|
951
|
+
input_->Advance(5);
|
952
|
+
return true;
|
1252
953
|
}
|
1253
954
|
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
955
|
+
bool Parse() {
|
956
|
+
auto cur = *input_->Next();
|
957
|
+
switch (cur >> 4) {
|
958
|
+
// Literal header not indexed - First byte format: 0000xxxx
|
959
|
+
// Literal header never indexed - First byte format: 0001xxxx
|
960
|
+
// Where xxxx:
|
961
|
+
// 0000 - literal key
|
962
|
+
// 1111 - indexed key, varint encoded index
|
963
|
+
// other - indexed key, inline encoded index
|
964
|
+
case 0:
|
965
|
+
case 1:
|
966
|
+
switch (cur & 0xf) {
|
967
|
+
case 0: // literal key
|
968
|
+
return FinishHeader<TableAction::kOmitFromTable>(
|
969
|
+
ParseLiteralKey<String::Extern>());
|
970
|
+
case 0xf: // varint encoded key index
|
971
|
+
return FinishHeader<TableAction::kOmitFromTable>(
|
972
|
+
ParseVarIdxKey<String::Extern>(0xf));
|
973
|
+
default: // inline encoded key index
|
974
|
+
return FinishHeader<TableAction::kOmitFromTable>(
|
975
|
+
ParseIdxKey<String::Extern>(cur & 0xf));
|
976
|
+
}
|
977
|
+
// Update max table size.
|
978
|
+
// First byte format: 001xxxxx
|
979
|
+
// Where xxxxx:
|
980
|
+
// 11111 - max size is varint encoded
|
981
|
+
// other - max size is stored inline
|
982
|
+
case 2:
|
983
|
+
// inline encoded max table size
|
984
|
+
return FinishMaxTableSize(cur & 0x1f);
|
985
|
+
case 3:
|
986
|
+
if (cur == 0x3f) {
|
987
|
+
// varint encoded max table size
|
988
|
+
return FinishMaxTableSize(input_->ParseVarint(0x1f));
|
989
|
+
} else {
|
990
|
+
// inline encoded max table size
|
991
|
+
return FinishMaxTableSize(cur & 0x1f);
|
992
|
+
}
|
993
|
+
// Literal header with incremental indexing.
|
994
|
+
// First byte format: 01xxxxxx
|
995
|
+
// Where xxxxxx:
|
996
|
+
// 000000 - literal key
|
997
|
+
// 111111 - indexed key, varint encoded index
|
998
|
+
// other - indexed key, inline encoded index
|
999
|
+
case 4:
|
1000
|
+
if (cur == 0x40) {
|
1001
|
+
// literal key
|
1002
|
+
return FinishHeader<TableAction::kAddToTable>(
|
1003
|
+
ParseLiteralKey<String::Intern>());
|
1004
|
+
}
|
1005
|
+
ABSL_FALLTHROUGH_INTENDED;
|
1006
|
+
case 5:
|
1007
|
+
case 6:
|
1008
|
+
// inline encoded key index
|
1009
|
+
return FinishHeader<TableAction::kAddToTable>(
|
1010
|
+
ParseIdxKey<String::Intern>(cur & 0x3f));
|
1011
|
+
case 7:
|
1012
|
+
if (cur == 0x7f) {
|
1013
|
+
// varint encoded key index
|
1014
|
+
return FinishHeader<TableAction::kAddToTable>(
|
1015
|
+
ParseVarIdxKey<String::Intern>(0x3f));
|
1016
|
+
} else {
|
1017
|
+
// inline encoded key index
|
1018
|
+
return FinishHeader<TableAction::kAddToTable>(
|
1019
|
+
ParseIdxKey<String::Intern>(cur & 0x3f));
|
1020
|
+
}
|
1021
|
+
// Indexed Header Field Representation
|
1022
|
+
// First byte format: 1xxxxxxx
|
1023
|
+
// Where xxxxxxx:
|
1024
|
+
// 0000000 - illegal
|
1025
|
+
// 1111111 - varint encoded field index
|
1026
|
+
// other - inline encoded field index
|
1027
|
+
case 8:
|
1028
|
+
if (cur == 0x80) {
|
1029
|
+
// illegal value.
|
1030
|
+
return input_->MaybeSetErrorAndReturn(
|
1031
|
+
[] {
|
1032
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1033
|
+
"Illegal hpack op code");
|
1034
|
+
},
|
1035
|
+
false);
|
1036
|
+
}
|
1037
|
+
ABSL_FALLTHROUGH_INTENDED;
|
1038
|
+
case 9:
|
1039
|
+
case 10:
|
1040
|
+
case 11:
|
1041
|
+
case 12:
|
1042
|
+
case 13:
|
1043
|
+
case 14:
|
1044
|
+
// inline encoded field index
|
1045
|
+
return FinishIndexed(cur & 0x7f);
|
1046
|
+
case 15:
|
1047
|
+
if (cur == 0xff) {
|
1048
|
+
// varint encoded field index
|
1049
|
+
return FinishIndexed(input_->ParseVarint(0x7f));
|
1050
|
+
} else {
|
1051
|
+
// inline encoded field index
|
1052
|
+
return FinishIndexed(cur & 0x7f);
|
1053
|
+
}
|
1054
|
+
}
|
1055
|
+
GPR_UNREACHABLE_CODE(abort());
|
1056
|
+
}
|
1262
1057
|
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1058
|
+
private:
|
1059
|
+
void GPR_ATTRIBUTE_NOINLINE LogHeader(grpc_mdelem md) {
|
1060
|
+
char* k = grpc_slice_to_c_string(GRPC_MDKEY(md));
|
1061
|
+
char* v = nullptr;
|
1062
|
+
if (grpc_is_binary_header_internal(GRPC_MDKEY(md))) {
|
1063
|
+
v = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX);
|
1064
|
+
} else {
|
1065
|
+
v = grpc_slice_to_c_string(GRPC_MDVALUE(md));
|
1066
|
+
}
|
1067
|
+
gpr_log(
|
1068
|
+
GPR_INFO,
|
1069
|
+
"Decode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d",
|
1070
|
+
k, v, GRPC_MDELEM_IS_INTERNED(md), GRPC_MDELEM_STORAGE(md),
|
1071
|
+
grpc_slice_is_interned(GRPC_MDKEY(md)),
|
1072
|
+
grpc_slice_is_interned(GRPC_MDVALUE(md)));
|
1073
|
+
gpr_free(k);
|
1074
|
+
gpr_free(v);
|
1270
1075
|
}
|
1271
1076
|
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1077
|
+
// During FinishHeader, how should the header be treated in the hpack table
|
1078
|
+
enum class TableAction {
|
1079
|
+
// Add to the table
|
1080
|
+
kAddToTable,
|
1081
|
+
// Do not add to the table
|
1082
|
+
kOmitFromTable,
|
1083
|
+
};
|
1084
|
+
|
1085
|
+
template <TableAction action>
|
1086
|
+
bool FinishHeader(grpc_mdelem md) {
|
1087
|
+
// Allow higher code to just pass in failures ... simplifies things a bit.
|
1088
|
+
if (GRPC_MDISNULL(md)) return false;
|
1089
|
+
// Log if desired
|
1090
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) {
|
1091
|
+
LogHeader(md);
|
1092
|
+
}
|
1093
|
+
// Add to the hpack table if needed
|
1094
|
+
if (action == TableAction::kAddToTable) {
|
1095
|
+
GPR_DEBUG_ASSERT(GRPC_MDELEM_STORAGE(md) ==
|
1096
|
+
GRPC_MDELEM_STORAGE_INTERNED ||
|
1097
|
+
GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC);
|
1098
|
+
grpc_error_handle err = table_->Add(md);
|
1099
|
+
if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) {
|
1100
|
+
input_->SetError(err);
|
1101
|
+
return false;
|
1102
|
+
};
|
1103
|
+
}
|
1104
|
+
// Pass up to the transport
|
1105
|
+
grpc_error_handle err = (*sink_)(md);
|
1106
|
+
if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) {
|
1107
|
+
input_->SetError(err);
|
1108
|
+
return false;
|
1109
|
+
}
|
1110
|
+
return true;
|
1279
1111
|
}
|
1280
|
-
}
|
1281
1112
|
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1113
|
+
// Parse a string encoded key and a string encoded value
|
1114
|
+
template <typename TakeValueType>
|
1115
|
+
grpc_mdelem ParseLiteralKey() {
|
1116
|
+
auto key = String::Parse(input_);
|
1117
|
+
if (!key.has_value()) return GRPC_MDNULL;
|
1118
|
+
auto key_slice = key->Take<String::Intern>();
|
1119
|
+
auto value = ParseValueString(key_slice);
|
1120
|
+
if (GPR_UNLIKELY(!value.has_value())) {
|
1121
|
+
grpc_slice_unref_internal(key_slice);
|
1122
|
+
return GRPC_MDNULL;
|
1123
|
+
}
|
1124
|
+
return grpc_mdelem_from_slices(key_slice, value->Take<TakeValueType>());
|
1292
1125
|
}
|
1293
|
-
memcpy(str->data.copied.str + str->data.copied.length, data, length);
|
1294
|
-
GPR_ASSERT(length <= UINT32_MAX - str->data.copied.length);
|
1295
|
-
str->data.copied.length += static_cast<uint32_t>(length);
|
1296
|
-
}
|
1297
1126
|
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
if (*cur == 0) {
|
1313
|
-
/* 'true-binary' case */
|
1314
|
-
++cur;
|
1315
|
-
p->binary = NOT_BINARY;
|
1316
|
-
GRPC_STATS_INC_HPACK_RECV_BINARY();
|
1317
|
-
append_bytes(str, cur, static_cast<size_t>(end - cur));
|
1318
|
-
return GRPC_ERROR_NONE;
|
1319
|
-
}
|
1320
|
-
GRPC_STATS_INC_HPACK_RECV_BINARY_BASE64();
|
1321
|
-
/* fallthrough */
|
1322
|
-
b64_byte0:
|
1323
|
-
case B64_BYTE0:
|
1324
|
-
if (cur == end) {
|
1325
|
-
p->binary = B64_BYTE0;
|
1326
|
-
return GRPC_ERROR_NONE;
|
1327
|
-
}
|
1328
|
-
bits = inverse_base64[*cur];
|
1329
|
-
++cur;
|
1330
|
-
if (bits == 255) {
|
1331
|
-
return parse_error(
|
1332
|
-
p, cur, end,
|
1333
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
|
1334
|
-
} else if (bits == 64) {
|
1335
|
-
goto b64_byte0;
|
1336
|
-
}
|
1337
|
-
p->base64_buffer = bits << 18;
|
1338
|
-
/* fallthrough */
|
1339
|
-
b64_byte1:
|
1340
|
-
case B64_BYTE1:
|
1341
|
-
if (cur == end) {
|
1342
|
-
p->binary = B64_BYTE1;
|
1343
|
-
return GRPC_ERROR_NONE;
|
1344
|
-
}
|
1345
|
-
bits = inverse_base64[*cur];
|
1346
|
-
++cur;
|
1347
|
-
if (bits == 255) {
|
1348
|
-
return parse_error(
|
1349
|
-
p, cur, end,
|
1350
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
|
1351
|
-
} else if (bits == 64) {
|
1352
|
-
goto b64_byte1;
|
1353
|
-
}
|
1354
|
-
p->base64_buffer |= bits << 12;
|
1355
|
-
/* fallthrough */
|
1356
|
-
b64_byte2:
|
1357
|
-
case B64_BYTE2:
|
1358
|
-
if (cur == end) {
|
1359
|
-
p->binary = B64_BYTE2;
|
1360
|
-
return GRPC_ERROR_NONE;
|
1361
|
-
}
|
1362
|
-
bits = inverse_base64[*cur];
|
1363
|
-
++cur;
|
1364
|
-
if (bits == 255) {
|
1365
|
-
return parse_error(
|
1366
|
-
p, cur, end,
|
1367
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
|
1368
|
-
} else if (bits == 64) {
|
1369
|
-
goto b64_byte2;
|
1370
|
-
}
|
1371
|
-
p->base64_buffer |= bits << 6;
|
1372
|
-
/* fallthrough */
|
1373
|
-
b64_byte3:
|
1374
|
-
case B64_BYTE3:
|
1375
|
-
if (cur == end) {
|
1376
|
-
p->binary = B64_BYTE3;
|
1377
|
-
return GRPC_ERROR_NONE;
|
1378
|
-
}
|
1379
|
-
bits = inverse_base64[*cur];
|
1380
|
-
++cur;
|
1381
|
-
if (bits == 255) {
|
1382
|
-
return parse_error(
|
1383
|
-
p, cur, end,
|
1384
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
|
1385
|
-
} else if (bits == 64) {
|
1386
|
-
goto b64_byte3;
|
1387
|
-
}
|
1388
|
-
p->base64_buffer |= bits;
|
1389
|
-
bits = p->base64_buffer;
|
1390
|
-
decoded[0] = static_cast<uint8_t>(bits >> 16);
|
1391
|
-
decoded[1] = static_cast<uint8_t>(bits >> 8);
|
1392
|
-
decoded[2] = static_cast<uint8_t>(bits);
|
1393
|
-
append_bytes(str, decoded, 3);
|
1394
|
-
goto b64_byte0;
|
1127
|
+
// Parse an index encoded key and a string encoded value
|
1128
|
+
template <typename TakeValueType>
|
1129
|
+
grpc_mdelem ParseIdxKey(uint32_t index) {
|
1130
|
+
auto elem = table_->Peek(index);
|
1131
|
+
if (GPR_UNLIKELY(GRPC_MDISNULL(elem))) {
|
1132
|
+
return InvalidHPackIndexError(index, elem);
|
1133
|
+
}
|
1134
|
+
GPR_DEBUG_ASSERT(GRPC_MDELEM_IS_INTERNED(elem));
|
1135
|
+
auto value = ParseValueString(GRPC_MDKEY(elem));
|
1136
|
+
if (GPR_UNLIKELY(!value.has_value())) return GRPC_MDNULL;
|
1137
|
+
return grpc_mdelem_from_slices(
|
1138
|
+
static_cast<const ManagedMemorySlice&>(
|
1139
|
+
grpc_slice_ref_internal(GRPC_MDKEY(elem))),
|
1140
|
+
value->Take<TakeValueType>());
|
1395
1141
|
}
|
1396
|
-
GPR_UNREACHABLE_CODE(return parse_error(
|
1397
|
-
p, cur, end,
|
1398
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Should never reach here")));
|
1399
|
-
}
|
1400
1142
|
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
case NOT_BINARY:
|
1408
|
-
break;
|
1409
|
-
case BINARY_BEGIN:
|
1410
|
-
break;
|
1411
|
-
case B64_BYTE0:
|
1412
|
-
break;
|
1413
|
-
case B64_BYTE1:
|
1414
|
-
return parse_error(p, cur, end,
|
1415
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1416
|
-
"illegal base64 encoding")); /* illegal encoding */
|
1417
|
-
case B64_BYTE2:
|
1418
|
-
bits = p->base64_buffer;
|
1419
|
-
if (bits & 0xffff) {
|
1420
|
-
grpc_error_handle err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1421
|
-
absl::StrFormat("trailing bits in base64 encoding: 0x%04x",
|
1422
|
-
bits & 0xffff)
|
1423
|
-
.c_str());
|
1424
|
-
return parse_error(p, cur, end, err);
|
1425
|
-
}
|
1426
|
-
decoded[0] = static_cast<uint8_t>(bits >> 16);
|
1427
|
-
append_bytes(str, decoded, 1);
|
1428
|
-
break;
|
1429
|
-
case B64_BYTE3:
|
1430
|
-
bits = p->base64_buffer;
|
1431
|
-
if (bits & 0xff) {
|
1432
|
-
grpc_error_handle err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1433
|
-
absl::StrFormat("trailing bits in base64 encoding: 0x%02x",
|
1434
|
-
bits & 0xff)
|
1435
|
-
.c_str());
|
1436
|
-
return parse_error(p, cur, end, err);
|
1437
|
-
}
|
1438
|
-
decoded[0] = static_cast<uint8_t>(bits >> 16);
|
1439
|
-
decoded[1] = static_cast<uint8_t>(bits >> 8);
|
1440
|
-
append_bytes(str, decoded, 2);
|
1441
|
-
break;
|
1143
|
+
// Parse a varint index encoded key and a string encoded value
|
1144
|
+
template <typename TakeValueType>
|
1145
|
+
grpc_mdelem ParseVarIdxKey(uint32_t offset) {
|
1146
|
+
auto index = input_->ParseVarint(offset);
|
1147
|
+
if (GPR_UNLIKELY(!index.has_value())) return GRPC_MDNULL;
|
1148
|
+
return ParseIdxKey<TakeValueType>(*index);
|
1442
1149
|
}
|
1443
|
-
return GRPC_ERROR_NONE;
|
1444
|
-
}
|
1445
1150
|
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
if (emit != -1) {
|
1452
|
-
if (emit >= 0 && emit < 256) {
|
1453
|
-
uint8_t c = static_cast<uint8_t>(emit);
|
1454
|
-
grpc_error_handle err = append_string(p, &c, (&c) + 1);
|
1455
|
-
if (err != GRPC_ERROR_NONE) return err;
|
1151
|
+
// Parse a string, figuring out if it's binary or not by the key name.
|
1152
|
+
template <typename SliceType>
|
1153
|
+
absl::optional<String> ParseValueString(const SliceType& key) {
|
1154
|
+
if (grpc_is_refcounted_slice_binary_header(key)) {
|
1155
|
+
return String::ParseBinary(input_);
|
1456
1156
|
} else {
|
1457
|
-
|
1157
|
+
return String::Parse(input_);
|
1458
1158
|
}
|
1459
1159
|
}
|
1460
|
-
p->huff_state = next;
|
1461
|
-
return GRPC_ERROR_NONE;
|
1462
|
-
}
|
1463
1160
|
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1161
|
+
// Emit an indexed field
|
1162
|
+
bool FinishIndexed(absl::optional<uint32_t> index) {
|
1163
|
+
*dynamic_table_updates_allowed_ = 0;
|
1164
|
+
if (!index.has_value()) return false;
|
1165
|
+
grpc_mdelem md = table_->Fetch(*index);
|
1166
|
+
if (GPR_UNLIKELY(GRPC_MDISNULL(md))) {
|
1167
|
+
return InvalidHPackIndexError(*index, false);
|
1168
|
+
}
|
1169
|
+
GRPC_STATS_INC_HPACK_RECV_INDEXED();
|
1170
|
+
return FinishHeader<TableAction::kOmitFromTable>(md);
|
1473
1171
|
}
|
1474
|
-
return GRPC_ERROR_NONE;
|
1475
|
-
}
|
1476
1172
|
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1173
|
+
// finish parsing a max table size change
|
1174
|
+
bool FinishMaxTableSize(absl::optional<uint32_t> size) {
|
1175
|
+
if (!size.has_value()) return false;
|
1176
|
+
if (*dynamic_table_updates_allowed_ == 0) {
|
1177
|
+
return input_->MaybeSetErrorAndReturn(
|
1178
|
+
[] {
|
1179
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1180
|
+
"More than two max table size changes in a single frame");
|
1181
|
+
},
|
1182
|
+
false);
|
1183
|
+
}
|
1184
|
+
(*dynamic_table_updates_allowed_)--;
|
1185
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) {
|
1186
|
+
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", *size);
|
1187
|
+
}
|
1188
|
+
grpc_error_handle err = table_->SetCurrentTableSize(*size);
|
1189
|
+
if (err != GRPC_ERROR_NONE) {
|
1190
|
+
input_->SetError(err);
|
1191
|
+
return false;
|
1192
|
+
}
|
1193
|
+
return true;
|
1485
1194
|
}
|
1486
|
-
}
|
1487
1195
|
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
p->strgot += static_cast<uint32_t>(given);
|
1504
|
-
p->state = parse_string;
|
1505
|
-
return GRPC_ERROR_NONE;
|
1196
|
+
// Set an invalid hpack index error if no error has been set. Returns result
|
1197
|
+
// unmodified.
|
1198
|
+
template <typename R>
|
1199
|
+
R InvalidHPackIndexError(uint32_t index, R result) {
|
1200
|
+
return input_->MaybeSetErrorAndReturn(
|
1201
|
+
[this, index] {
|
1202
|
+
return grpc_error_set_int(
|
1203
|
+
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1204
|
+
"Invalid HPACK index received"),
|
1205
|
+
GRPC_ERROR_INT_INDEX,
|
1206
|
+
static_cast<intptr_t>(index)),
|
1207
|
+
GRPC_ERROR_INT_SIZE,
|
1208
|
+
static_cast<intptr_t>(this->table_->num_entries()));
|
1209
|
+
},
|
1210
|
+
result);
|
1506
1211
|
}
|
1507
|
-
}
|
1508
1212
|
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
static_cast<uint32_t>(end - cur) >= p->strlen &&
|
1515
|
-
p->current_slice_refcount != nullptr) {
|
1516
|
-
GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED();
|
1517
|
-
str->copied = false;
|
1518
|
-
str->data.referenced.refcount = p->current_slice_refcount;
|
1519
|
-
str->data.referenced.data.refcounted.bytes = const_cast<uint8_t*>(cur);
|
1520
|
-
str->data.referenced.data.refcounted.length = p->strlen;
|
1521
|
-
grpc_slice_ref_internal(str->data.referenced);
|
1522
|
-
return parse_next(p, cur + p->strlen, end);
|
1523
|
-
}
|
1524
|
-
p->strgot = 0;
|
1525
|
-
str->copied = true;
|
1526
|
-
str->data.copied.length = 0;
|
1527
|
-
p->parsing.str = str;
|
1528
|
-
p->huff_state = 0;
|
1529
|
-
p->binary = binary;
|
1530
|
-
switch (p->binary) {
|
1531
|
-
case NOT_BINARY:
|
1532
|
-
if (p->huff) {
|
1533
|
-
GRPC_STATS_INC_HPACK_RECV_HUFFMAN();
|
1534
|
-
} else {
|
1535
|
-
GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED();
|
1536
|
-
}
|
1537
|
-
break;
|
1538
|
-
case BINARY_BEGIN:
|
1539
|
-
/* stats incremented later: don't know true binary or not */
|
1540
|
-
break;
|
1541
|
-
default:
|
1542
|
-
abort();
|
1543
|
-
}
|
1544
|
-
return parse_string(p, cur, end);
|
1545
|
-
}
|
1213
|
+
Input* input_;
|
1214
|
+
HPackParser::Sink* sink_;
|
1215
|
+
HPackTable* const table_;
|
1216
|
+
uint8_t* dynamic_table_updates_allowed_;
|
1217
|
+
};
|
1546
1218
|
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1219
|
+
UnmanagedMemorySlice HPackParser::String::Take(Extern) {
|
1220
|
+
auto s = Match(
|
1221
|
+
value_,
|
1222
|
+
[](const grpc_slice& slice) {
|
1223
|
+
GPR_DEBUG_ASSERT(!grpc_slice_is_interned(slice));
|
1224
|
+
return static_cast<const UnmanagedMemorySlice&>(slice);
|
1225
|
+
},
|
1226
|
+
[](absl::Span<const uint8_t> span) {
|
1227
|
+
return UnmanagedMemorySlice(
|
1228
|
+
reinterpret_cast<char*>(const_cast<uint8_t*>(span.begin())),
|
1229
|
+
span.size());
|
1230
|
+
},
|
1231
|
+
[](const std::vector<uint8_t>& v) {
|
1232
|
+
return UnmanagedMemorySlice(reinterpret_cast<const char*>(v.data()),
|
1233
|
+
v.size());
|
1234
|
+
});
|
1235
|
+
value_ = absl::Span<const uint8_t>();
|
1236
|
+
return s;
|
1552
1237
|
}
|
1553
1238
|
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1239
|
+
ManagedMemorySlice HPackParser::String::Take(Intern) {
|
1240
|
+
auto s = Match(
|
1241
|
+
value_,
|
1242
|
+
[](const grpc_slice& slice) {
|
1243
|
+
ManagedMemorySlice s(&slice);
|
1244
|
+
grpc_slice_unref_internal(slice);
|
1245
|
+
return s;
|
1246
|
+
},
|
1247
|
+
[](absl::Span<const uint8_t> span) {
|
1248
|
+
return ManagedMemorySlice(
|
1249
|
+
reinterpret_cast<char*>(const_cast<uint8_t*>(span.data())),
|
1250
|
+
span.size());
|
1251
|
+
},
|
1252
|
+
[](const std::vector<uint8_t>& v) {
|
1253
|
+
return ManagedMemorySlice(reinterpret_cast<const char*>(v.data()),
|
1254
|
+
v.size());
|
1255
|
+
});
|
1256
|
+
value_ = absl::Span<const uint8_t>();
|
1257
|
+
return s;
|
1566
1258
|
}
|
1567
1259
|
|
1568
|
-
/*
|
1569
|
-
pointless recomputation of the metadata when finishing a header. We read the
|
1570
|
-
cached value in get_precomputed_md_for_idx(). */
|
1571
|
-
static void set_precomputed_md_idx(grpc_chttp2_hpack_parser* p,
|
1572
|
-
grpc_mdelem md) {
|
1573
|
-
GPR_DEBUG_ASSERT(p->md_for_index.payload == 0);
|
1574
|
-
GPR_DEBUG_ASSERT(p->precomputed_md_index == -1);
|
1575
|
-
p->md_for_index = md;
|
1576
|
-
#ifndef NDEBUG
|
1577
|
-
p->precomputed_md_index = p->index;
|
1578
|
-
#endif
|
1579
|
-
}
|
1260
|
+
/* PUBLIC INTERFACE */
|
1580
1261
|
|
1581
|
-
|
1582
|
-
is a binary indexed header during string parsing. We'll need to revisit this
|
1583
|
-
metadata when we're done parsing, so we cache the metadata for this index
|
1584
|
-
here using set_precomputed_md_idx(). */
|
1585
|
-
static grpc_error_handle is_binary_indexed_header(grpc_chttp2_hpack_parser* p,
|
1586
|
-
bool* is) {
|
1587
|
-
grpc_mdelem elem = grpc_chttp2_hptbl_lookup(&p->table, p->index);
|
1588
|
-
if (GPR_UNLIKELY(GRPC_MDISNULL(elem))) {
|
1589
|
-
return on_invalid_hpack_idx(p);
|
1590
|
-
}
|
1591
|
-
/* We know that GRPC_MDKEY(elem) points to a reference counted slice since:
|
1592
|
-
* 1. elem was a result of grpc_chttp2_hptbl_lookup
|
1593
|
-
* 2. An item in this table is either static (see entries with
|
1594
|
-
* index < GRPC_CHTTP2_LAST_STATIC_ENTRY or added via
|
1595
|
-
* grpc_chttp2_hptbl_add).
|
1596
|
-
* 3. If added via grpc_chttp2_hptbl_add, the entry is either static or
|
1597
|
-
* interned.
|
1598
|
-
* 4. Both static and interned element slices have non-null refcounts. */
|
1599
|
-
*is = grpc_is_refcounted_slice_binary_header(GRPC_MDKEY(elem));
|
1600
|
-
set_precomputed_md_idx(p, elem);
|
1601
|
-
return GRPC_ERROR_NONE;
|
1602
|
-
}
|
1262
|
+
HPackParser::HPackParser() = default;
|
1603
1263
|
|
1604
|
-
|
1605
|
-
static grpc_error_handle parse_value_string(grpc_chttp2_hpack_parser* p,
|
1606
|
-
const uint8_t* cur,
|
1607
|
-
const uint8_t* end,
|
1608
|
-
bool is_binary) {
|
1609
|
-
return begin_parse_string(p, cur, end, is_binary ? BINARY_BEGIN : NOT_BINARY,
|
1610
|
-
&p->value);
|
1611
|
-
}
|
1264
|
+
HPackParser::~HPackParser() = default;
|
1612
1265
|
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
return parse_value_string(p, cur, end, is_binary);
|
1266
|
+
void HPackParser::BeginFrame(Sink sink, Boundary boundary, Priority priority) {
|
1267
|
+
sink_ = std::move(sink);
|
1268
|
+
boundary_ = boundary;
|
1269
|
+
priority_ = priority;
|
1270
|
+
dynamic_table_updates_allowed_ = 2;
|
1619
1271
|
}
|
1620
1272
|
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1273
|
+
grpc_error_handle HPackParser::Parse(const grpc_slice& slice, bool is_last) {
|
1274
|
+
if (GPR_UNLIKELY(!unparsed_bytes_.empty())) {
|
1275
|
+
std::vector<uint8_t> buffer = std::move(unparsed_bytes_);
|
1276
|
+
buffer.insert(buffer.end(), GRPC_SLICE_START_PTR(slice),
|
1277
|
+
GRPC_SLICE_END_PTR(slice));
|
1278
|
+
return ParseInput(
|
1279
|
+
Input(nullptr, buffer.data(), buffer.data() + buffer.size()), is_last);
|
1280
|
+
}
|
1281
|
+
return ParseInput(Input(slice.refcount, GRPC_SLICE_START_PTR(slice),
|
1282
|
+
GRPC_SLICE_END_PTR(slice)),
|
1283
|
+
is_last);
|
1624
1284
|
}
|
1625
1285
|
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1286
|
+
grpc_error_handle HPackParser::ParseInput(Input input, bool is_last) {
|
1287
|
+
if (ParseInputInner(&input)) {
|
1288
|
+
return GRPC_ERROR_NONE;
|
1289
|
+
}
|
1290
|
+
if (input.eof_error()) {
|
1291
|
+
if (GPR_UNLIKELY(is_last && is_boundary())) {
|
1292
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1293
|
+
"Incomplete header at the end of a header/continuation sequence");
|
1294
|
+
}
|
1295
|
+
unparsed_bytes_ = std::vector<uint8_t>(input.frontier(), input.end_ptr());
|
1296
|
+
return GRPC_ERROR_NONE;
|
1297
|
+
}
|
1298
|
+
return input.TakeError();
|
1631
1299
|
}
|
1632
1300
|
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
p->md_for_index.payload = 0;
|
1654
|
-
#ifndef NDEBUG
|
1655
|
-
/* In debug mode, this ensures that the cached metadata we're reading is in
|
1656
|
-
* fact correct for the index we are examining. */
|
1657
|
-
p->precomputed_md_index = -1;
|
1658
|
-
#endif
|
1659
|
-
p->dynamic_table_update_allowed = 2;
|
1660
|
-
p->last_error = GRPC_ERROR_NONE;
|
1301
|
+
bool HPackParser::ParseInputInner(Input* input) {
|
1302
|
+
switch (priority_) {
|
1303
|
+
case Priority::None:
|
1304
|
+
break;
|
1305
|
+
case Priority::Included: {
|
1306
|
+
if (input->remaining() < 5) return input->UnexpectedEOF(false);
|
1307
|
+
input->Advance(5);
|
1308
|
+
input->UpdateFrontier();
|
1309
|
+
priority_ = Priority::None;
|
1310
|
+
}
|
1311
|
+
}
|
1312
|
+
while (!input->end_of_stream()) {
|
1313
|
+
if (GPR_UNLIKELY(
|
1314
|
+
!Parser(input, &sink_, &table_, &dynamic_table_updates_allowed_)
|
1315
|
+
.Parse())) {
|
1316
|
+
return false;
|
1317
|
+
}
|
1318
|
+
input->UpdateFrontier();
|
1319
|
+
}
|
1320
|
+
return true;
|
1661
1321
|
}
|
1662
1322
|
|
1663
|
-
void
|
1664
|
-
p->after_prioritization = p->state;
|
1665
|
-
p->state = parse_stream_dep0;
|
1666
|
-
}
|
1323
|
+
void HPackParser::FinishFrame() { sink_ = Sink(); }
|
1667
1324
|
|
1668
|
-
|
1669
|
-
grpc_chttp2_hptbl_destroy(&p->table);
|
1670
|
-
GRPC_ERROR_UNREF(p->last_error);
|
1671
|
-
grpc_slice_unref_internal(p->key.data.referenced);
|
1672
|
-
grpc_slice_unref_internal(p->value.data.referenced);
|
1673
|
-
gpr_free(p->key.data.copied.str);
|
1674
|
-
gpr_free(p->value.data.copied.str);
|
1675
|
-
}
|
1325
|
+
} // namespace grpc_core
|
1676
1326
|
|
1677
|
-
|
1678
|
-
|
1679
|
-
/* max number of bytes to parse at a time... limits call stack depth on
|
1680
|
-
* compilers without TCO */
|
1681
|
-
#define MAX_PARSE_LENGTH 1024
|
1682
|
-
p->current_slice_refcount = slice.refcount;
|
1683
|
-
const uint8_t* start = GRPC_SLICE_START_PTR(slice);
|
1684
|
-
const uint8_t* end = GRPC_SLICE_END_PTR(slice);
|
1685
|
-
grpc_error_handle error = GRPC_ERROR_NONE;
|
1686
|
-
while (start != end && error == GRPC_ERROR_NONE) {
|
1687
|
-
const uint8_t* target = start + GPR_MIN(MAX_PARSE_LENGTH, end - start);
|
1688
|
-
error = p->state(p, start, target);
|
1689
|
-
start = target;
|
1690
|
-
}
|
1691
|
-
p->current_slice_refcount = nullptr;
|
1692
|
-
return error;
|
1693
|
-
}
|
1327
|
+
// TODO(ctiller): this serves as an eviction notice for the remainder of this
|
1328
|
+
// file... it belongs elsewhere!
|
1694
1329
|
|
1695
1330
|
typedef void (*maybe_complete_func_type)(grpc_chttp2_transport* t,
|
1696
1331
|
grpc_chttp2_stream* s);
|
@@ -1734,24 +1369,19 @@ grpc_error_handle grpc_chttp2_header_parser_parse(void* hpack_parser,
|
|
1734
1369
|
const grpc_slice& slice,
|
1735
1370
|
int is_last) {
|
1736
1371
|
GPR_TIMER_SCOPE("grpc_chttp2_header_parser_parse", 0);
|
1737
|
-
|
1738
|
-
static_cast<grpc_chttp2_hpack_parser*>(hpack_parser);
|
1372
|
+
auto* parser = static_cast<grpc_core::HPackParser*>(hpack_parser);
|
1739
1373
|
if (s != nullptr) {
|
1740
1374
|
s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice);
|
1741
1375
|
}
|
1742
|
-
grpc_error_handle error =
|
1376
|
+
grpc_error_handle error = parser->Parse(slice, is_last != 0);
|
1743
1377
|
if (error != GRPC_ERROR_NONE) {
|
1744
1378
|
return error;
|
1745
1379
|
}
|
1746
1380
|
if (is_last) {
|
1747
|
-
if (parser->is_boundary && parser->state != parse_begin) {
|
1748
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1749
|
-
"end of header frame not aligned with a hpack record boundary");
|
1750
|
-
}
|
1751
1381
|
/* need to check for null stream: this can occur if we receive an invalid
|
1752
1382
|
stream id on a header */
|
1753
1383
|
if (s != nullptr) {
|
1754
|
-
if (parser->is_boundary) {
|
1384
|
+
if (parser->is_boundary()) {
|
1755
1385
|
if (s->header_frames_received == GPR_ARRAY_SIZE(s->metadata_buffer)) {
|
1756
1386
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1757
1387
|
"Too many trailer frames");
|
@@ -1766,7 +1396,7 @@ grpc_error_handle grpc_chttp2_header_parser_parse(void* hpack_parser,
|
|
1766
1396
|
maybe_complete_funcs[s->header_frames_received](t, s);
|
1767
1397
|
s->header_frames_received++;
|
1768
1398
|
}
|
1769
|
-
if (parser->is_eof) {
|
1399
|
+
if (parser->is_eof()) {
|
1770
1400
|
if (t->is_client && !s->write_closed) {
|
1771
1401
|
/* server eof ==> complete closure; we may need to forcefully close
|
1772
1402
|
the stream. Wait until the combiner lock is ready to be released
|
@@ -1780,11 +1410,7 @@ grpc_error_handle grpc_chttp2_header_parser_parse(void* hpack_parser,
|
|
1780
1410
|
grpc_chttp2_mark_stream_closed(t, s, true, false, GRPC_ERROR_NONE);
|
1781
1411
|
}
|
1782
1412
|
}
|
1783
|
-
parser->
|
1784
|
-
parser->on_header_user_data = nullptr;
|
1785
|
-
parser->is_boundary = 0xde;
|
1786
|
-
parser->is_eof = 0xde;
|
1787
|
-
parser->dynamic_table_update_allowed = 2;
|
1413
|
+
parser->FinishFrame();
|
1788
1414
|
}
|
1789
1415
|
return GRPC_ERROR_NONE;
|
1790
1416
|
}
|