grpc 1.37.1 → 1.40.0.pre1
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 +112 -59
- data/include/grpc/event_engine/README.md +38 -0
- data/include/grpc/event_engine/endpoint_config.h +48 -0
- data/include/grpc/event_engine/event_engine.h +330 -0
- data/include/grpc/event_engine/port.h +41 -0
- data/include/grpc/event_engine/slice_allocator.h +66 -0
- data/include/grpc/grpc.h +11 -4
- data/include/grpc/grpc_security.h +32 -0
- data/include/grpc/grpc_security_constants.h +15 -0
- data/include/grpc/impl/codegen/grpc_types.h +44 -19
- data/include/grpc/impl/codegen/port_platform.h +46 -0
- data/include/grpc/module.modulemap +14 -14
- data/src/core/ext/filters/client_channel/backup_poller.cc +3 -3
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +177 -202
- data/src/core/ext/filters/client_channel/client_channel.cc +975 -3282
- data/src/core/ext/filters/client_channel/client_channel.h +513 -55
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +4 -1
- data/src/core/ext/filters/client_channel/config_selector.h +20 -7
- data/src/core/ext/filters/client_channel/connector.h +1 -1
- data/src/core/ext/filters/client_channel/dynamic_filters.cc +9 -10
- data/src/core/ext/filters/client_channel/dynamic_filters.h +3 -3
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +28 -27
- data/src/core/ext/filters/client_channel/health/health_check_client.h +30 -29
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +24 -21
- data/src/core/ext/filters/client_channel/http_proxy.cc +16 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +6 -6
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +53 -51
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +2 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +14 -23
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +16 -16
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +734 -0
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -0
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +10 -17
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +17 -20
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +53 -65
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +36 -44
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +33 -55
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +151 -163
- data/src/core/ext/filters/client_channel/lb_policy.cc +2 -16
- data/src/core/ext/filters/client_channel/lb_policy.h +70 -46
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +4 -4
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +24 -18
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc +31 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +3 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +14 -14
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +33 -24
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc +28 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +18 -12
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +20 -28
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +7 -5
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +20 -13
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +158 -102
- data/src/core/ext/filters/client_channel/resolver.h +2 -2
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +32 -239
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +20 -49
- data/src/core/ext/filters/client_channel/retry_filter.cc +2598 -0
- data/src/core/ext/filters/client_channel/retry_filter.h +30 -0
- data/src/core/ext/filters/client_channel/retry_service_config.cc +316 -0
- data/src/core/ext/filters/client_channel/retry_service_config.h +96 -0
- data/src/core/ext/filters/client_channel/server_address.cc +1 -1
- data/src/core/ext/filters/client_channel/service_config.cc +15 -14
- data/src/core/ext/filters/client_channel/service_config.h +7 -6
- data/src/core/ext/filters/client_channel/service_config_call_data.h +45 -5
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +5 -4
- data/src/core/ext/filters/client_channel/service_config_parser.cc +6 -6
- data/src/core/ext/filters/client_channel/service_config_parser.h +7 -4
- data/src/core/ext/filters/client_channel/subchannel.cc +17 -16
- data/src/core/ext/filters/client_channel/subchannel.h +7 -6
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +17 -16
- data/src/core/ext/filters/deadline/deadline_filter.cc +10 -10
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +19 -18
- data/src/core/ext/filters/fault_injection/service_config_parser.cc +5 -5
- data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
- data/src/core/ext/filters/http/client/http_client_filter.cc +33 -23
- data/src/core/ext/filters/http/client_authority_filter.cc +3 -3
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +23 -22
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +21 -21
- data/src/core/ext/filters/http/server/http_server_filter.cc +27 -23
- data/src/core/ext/filters/max_age/max_age_filter.cc +12 -10
- data/src/core/ext/filters/message_size/message_size_filter.cc +14 -11
- data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +4 -3
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +7 -7
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +7 -7
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +2 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +3 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +3 -3
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +49 -46
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +2 -2
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +3 -4
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +5 -4
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +3 -4
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.cc +66 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h +74 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +141 -126
- data/src/core/ext/transport/chttp2/transport/context_list.cc +4 -5
- data/src/core/ext/transport/chttp2/transport/context_list.h +4 -4
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +3 -3
- data/src/core/ext/transport/chttp2/transport/flow_control.h +9 -9
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +12 -12
- data/src/core/ext/transport/chttp2/transport/frame_data.h +10 -10
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +15 -16
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +6 -6
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +7 -8
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +7 -6
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +7 -7
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +6 -6
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +11 -10
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +6 -6
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +4 -6
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +4 -6
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +652 -736
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +195 -74
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +4 -3
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +4 -4
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +2 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +33 -28
- data/src/core/ext/transport/chttp2/transport/parsing.cc +129 -106
- data/src/core/ext/transport/chttp2/transport/varint.cc +6 -4
- data/src/core/ext/transport/chttp2/transport/writing.cc +7 -3
- data/src/core/ext/transport/inproc/inproc_transport.cc +72 -60
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +56 -35
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +180 -76
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +35 -27
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +97 -48
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +45 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +67 -7
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +66 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +227 -0
- 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 +121 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +1 -0
- 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 +90 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +32 -24
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +120 -73
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +4 -2
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +15 -0
- 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 +171 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +8 -6
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +27 -19
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +24 -7
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +57 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +29 -17
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +72 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +3 -2
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +4 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +6 -5
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +15 -11
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +85 -43
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +274 -91
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +11 -8
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +30 -13
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +33 -5
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +115 -0
- 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 +181 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +1 -0
- data/src/core/ext/upb-generated/validate/validate.upb.c +82 -66
- data/src/core/ext/upb-generated/validate/validate.upb.h +220 -124
- 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 +437 -410
- 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/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/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 +684 -664
- 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 +441 -375
- 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 +122 -114
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +1 -1
- 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/regex.upbdefs.c +35 -32
- 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_factory.h +1 -1
- data/src/core/ext/xds/certificate_provider_store.h +3 -3
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +3 -3
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +2 -2
- data/src/core/ext/xds/xds_api.cc +665 -317
- data/src/core/ext/xds/xds_api.h +52 -14
- data/src/core/ext/xds/xds_bootstrap.cc +101 -160
- data/src/core/ext/xds/xds_bootstrap.h +19 -24
- data/src/core/ext/xds/xds_certificate_provider.cc +4 -4
- data/src/core/ext/xds/xds_certificate_provider.h +4 -4
- data/src/core/ext/xds/xds_channel_args.h +5 -2
- data/src/core/ext/xds/xds_client.cc +370 -215
- data/src/core/ext/xds/xds_client.h +38 -28
- data/src/core/ext/xds/xds_client_stats.h +3 -2
- data/src/core/ext/xds/xds_http_filters.cc +3 -2
- data/src/core/ext/xds/xds_http_filters.h +3 -0
- data/src/core/ext/xds/xds_server_config_fetcher.cc +34 -20
- data/src/core/lib/{iomgr → address_utils}/parse_address.cc +17 -17
- data/src/core/lib/{iomgr → address_utils}/parse_address.h +7 -7
- data/src/core/lib/{iomgr → address_utils}/sockaddr_utils.cc +16 -20
- data/src/core/lib/{iomgr → address_utils}/sockaddr_utils.h +16 -11
- data/src/core/lib/channel/call_tracer.h +85 -0
- data/src/core/lib/channel/channel_stack.cc +10 -9
- data/src/core/lib/channel/channel_stack.h +11 -10
- data/src/core/lib/channel/channel_stack_builder.cc +2 -2
- data/src/core/lib/channel/channel_stack_builder.h +1 -1
- data/src/core/lib/channel/channelz.cc +21 -13
- data/src/core/lib/channel/channelz.h +3 -0
- data/src/core/lib/channel/connected_channel.cc +4 -4
- data/src/core/lib/channel/context.h +3 -0
- data/src/core/lib/channel/handshaker.cc +7 -6
- data/src/core/lib/channel/handshaker.h +5 -5
- data/src/core/lib/channel/status_util.h +4 -0
- data/src/core/lib/compression/stream_compression.h +1 -1
- data/src/core/lib/compression/stream_compression_gzip.h +1 -1
- data/src/core/lib/compression/stream_compression_identity.h +1 -1
- data/src/core/lib/debug/stats.h +1 -1
- data/src/core/lib/event_engine/endpoint_config.cc +46 -0
- data/src/core/lib/event_engine/endpoint_config_internal.h +42 -0
- data/src/core/lib/event_engine/event_engine.cc +50 -0
- data/src/core/lib/event_engine/sockaddr.cc +40 -0
- data/src/core/lib/event_engine/sockaddr.h +44 -0
- data/src/core/lib/gpr/murmur_hash.cc +4 -2
- data/src/core/lib/gpr/wrap_memcpy.cc +2 -1
- data/src/core/lib/gprpp/manual_constructor.h +1 -1
- data/src/core/lib/gprpp/orphanable.h +3 -3
- data/src/core/lib/gprpp/ref_counted.h +28 -14
- data/src/core/lib/gprpp/status_helper.cc +407 -0
- data/src/core/lib/gprpp/status_helper.h +183 -0
- data/src/core/lib/gprpp/sync.h +2 -30
- data/src/core/lib/http/httpcli.cc +11 -11
- data/src/core/lib/http/httpcli_security_connector.cc +11 -7
- data/src/core/lib/http/parser.cc +16 -16
- data/src/core/lib/http/parser.h +4 -4
- data/src/core/lib/iomgr/buffer_list.cc +8 -10
- data/src/core/lib/iomgr/buffer_list.h +4 -5
- data/src/core/lib/iomgr/call_combiner.cc +15 -12
- data/src/core/lib/iomgr/call_combiner.h +12 -14
- data/src/core/lib/iomgr/cfstream_handle.cc +3 -3
- data/src/core/lib/iomgr/cfstream_handle.h +1 -1
- data/src/core/lib/iomgr/closure.h +7 -6
- data/src/core/lib/iomgr/combiner.cc +14 -12
- data/src/core/lib/iomgr/combiner.h +2 -2
- data/src/core/lib/iomgr/endpoint.cc +1 -1
- data/src/core/lib/iomgr/endpoint.h +2 -2
- data/src/core/lib/iomgr/endpoint_cfstream.cc +11 -13
- data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +33 -0
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +1 -1
- data/src/core/lib/iomgr/error.cc +168 -61
- data/src/core/lib/iomgr/error.h +217 -106
- data/src/core/lib/iomgr/error_cfstream.cc +3 -2
- data/src/core/lib/iomgr/error_cfstream.h +2 -2
- data/src/core/lib/iomgr/error_internal.h +5 -1
- data/src/core/lib/iomgr/ev_apple.cc +5 -5
- data/src/core/lib/iomgr/ev_apple.h +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +19 -19
- data/src/core/lib/iomgr/ev_epollex_linux.cc +48 -45
- data/src/core/lib/iomgr/ev_poll_posix.cc +26 -23
- data/src/core/lib/iomgr/ev_posix.cc +9 -8
- data/src/core/lib/iomgr/ev_posix.h +9 -9
- data/src/core/lib/iomgr/event_engine/closure.cc +54 -0
- data/src/core/lib/iomgr/event_engine/closure.h +33 -0
- data/src/core/lib/iomgr/event_engine/endpoint.cc +192 -0
- data/src/core/lib/iomgr/event_engine/endpoint.h +53 -0
- data/src/core/lib/iomgr/event_engine/iomgr.cc +105 -0
- data/src/core/lib/iomgr/event_engine/iomgr.h +24 -0
- data/src/core/lib/iomgr/event_engine/pollset.cc +87 -0
- data/src/core/lib/iomgr/event_engine/pollset.h +25 -0
- data/src/core/lib/iomgr/event_engine/promise.h +51 -0
- data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +41 -0
- data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +35 -0
- data/src/core/lib/iomgr/event_engine/resolver.cc +110 -0
- data/src/core/lib/iomgr/event_engine/tcp.cc +263 -0
- data/src/core/lib/iomgr/event_engine/timer.cc +57 -0
- data/src/core/lib/iomgr/exec_ctx.cc +12 -4
- data/src/core/lib/iomgr/exec_ctx.h +4 -5
- data/src/core/lib/iomgr/executor/threadpool.cc +2 -3
- data/src/core/lib/iomgr/executor/threadpool.h +2 -2
- data/src/core/lib/iomgr/executor.cc +8 -8
- data/src/core/lib/iomgr/executor.h +2 -2
- data/src/core/lib/iomgr/iomgr.cc +2 -2
- data/src/core/lib/iomgr/iomgr.h +1 -1
- data/src/core/lib/iomgr/iomgr_custom.cc +1 -1
- data/src/core/lib/iomgr/iomgr_internal.cc +2 -2
- data/src/core/lib/iomgr/iomgr_internal.h +3 -3
- data/src/core/lib/iomgr/iomgr_posix.cc +3 -1
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +42 -12
- data/src/core/lib/iomgr/iomgr_windows.cc +1 -1
- data/src/core/lib/iomgr/load_file.cc +4 -4
- data/src/core/lib/iomgr/load_file.h +2 -2
- data/src/core/lib/iomgr/lockfree_event.cc +5 -5
- data/src/core/lib/iomgr/lockfree_event.h +1 -1
- data/src/core/lib/iomgr/pollset.cc +5 -5
- data/src/core/lib/iomgr/pollset.h +9 -9
- data/src/core/lib/iomgr/pollset_custom.cc +7 -7
- data/src/core/lib/iomgr/pollset_custom.h +3 -1
- data/src/core/lib/iomgr/pollset_uv.cc +3 -1
- data/src/core/lib/iomgr/pollset_uv.h +5 -1
- data/src/core/lib/iomgr/pollset_windows.cc +5 -5
- data/src/core/lib/iomgr/port.h +7 -5
- data/src/core/lib/iomgr/python_util.h +2 -2
- data/src/core/lib/iomgr/resolve_address.cc +8 -4
- data/src/core/lib/iomgr/resolve_address.h +12 -6
- data/src/core/lib/iomgr/resolve_address_custom.cc +10 -9
- data/src/core/lib/iomgr/resolve_address_custom.h +3 -3
- data/src/core/lib/iomgr/resolve_address_posix.cc +3 -3
- data/src/core/lib/iomgr/resolve_address_windows.cc +4 -4
- data/src/core/lib/iomgr/resource_quota.cc +13 -10
- data/src/core/lib/iomgr/sockaddr.h +1 -0
- data/src/core/lib/iomgr/socket_mutator.cc +15 -2
- data/src/core/lib/iomgr/socket_mutator.h +26 -2
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +24 -22
- data/src/core/lib/iomgr/socket_utils_posix.h +20 -20
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +4 -4
- data/src/core/lib/iomgr/tcp_client_custom.cc +5 -6
- data/src/core/lib/iomgr/tcp_client_posix.cc +22 -19
- data/src/core/lib/iomgr/tcp_client_posix.h +3 -4
- data/src/core/lib/iomgr/tcp_client_windows.cc +7 -5
- data/src/core/lib/iomgr/tcp_custom.cc +14 -16
- data/src/core/lib/iomgr/tcp_custom.h +13 -12
- data/src/core/lib/iomgr/tcp_posix.cc +78 -73
- data/src/core/lib/iomgr/tcp_posix.h +8 -0
- data/src/core/lib/iomgr/tcp_server.cc +6 -6
- data/src/core/lib/iomgr/tcp_server.h +12 -11
- data/src/core/lib/iomgr/tcp_server_custom.cc +26 -25
- data/src/core/lib/iomgr/tcp_server_posix.cc +29 -21
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +13 -12
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +21 -18
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +9 -9
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +4 -4
- data/src/core/lib/iomgr/tcp_server_windows.cc +26 -25
- data/src/core/lib/iomgr/tcp_uv.cc +25 -23
- data/src/core/lib/iomgr/tcp_windows.cc +13 -13
- data/src/core/lib/iomgr/tcp_windows.h +2 -2
- data/src/core/lib/iomgr/timer.h +6 -1
- data/src/core/lib/iomgr/timer_custom.cc +2 -1
- data/src/core/lib/iomgr/timer_custom.h +1 -1
- data/src/core/lib/iomgr/timer_generic.cc +6 -6
- data/src/core/lib/iomgr/timer_manager.cc +1 -1
- data/src/core/lib/iomgr/udp_server.cc +21 -20
- data/src/core/lib/iomgr/unix_sockets_posix.cc +3 -3
- data/src/core/lib/iomgr/unix_sockets_posix.h +2 -2
- data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +10 -7
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +3 -3
- data/src/core/lib/iomgr/wakeup_fd_pipe.cc +4 -4
- data/src/core/lib/iomgr/wakeup_fd_posix.cc +3 -3
- data/src/core/lib/iomgr/wakeup_fd_posix.h +8 -6
- data/src/core/lib/iomgr/work_serializer.h +17 -1
- data/src/core/lib/json/json.h +1 -1
- data/src/core/lib/json/json_reader.cc +5 -6
- data/src/core/lib/matchers/matchers.cc +46 -58
- data/src/core/lib/matchers/matchers.h +30 -29
- data/src/core/lib/security/authorization/authorization_engine.h +44 -0
- data/src/core/lib/security/authorization/authorization_policy_provider.h +32 -0
- data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +46 -0
- data/src/core/lib/security/authorization/evaluate_args.cc +209 -0
- data/src/core/lib/security/authorization/evaluate_args.h +91 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +4 -4
- data/src/core/lib/security/credentials/composite/composite_credentials.h +2 -2
- data/src/core/lib/security/credentials/credentials.h +2 -2
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +17 -13
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +13 -11
- data/src/core/lib/security/credentials/external/aws_request_signer.cc +2 -1
- data/src/core/lib/security/credentials/external/aws_request_signer.h +1 -1
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +15 -12
- data/src/core/lib/security/credentials/external/external_account_credentials.h +9 -8
- data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +5 -4
- data/src/core/lib/security/credentials/external/file_external_account_credentials.h +4 -3
- data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +8 -8
- data/src/core/lib/security/credentials/external/url_external_account_credentials.h +9 -7
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +2 -2
- data/src/core/lib/security/credentials/fake/fake_credentials.h +2 -2
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +12 -10
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +2 -2
- data/src/core/lib/security/credentials/iam/iam_credentials.h +2 -2
- data/src/core/lib/security/credentials/jwt/json_token.cc +2 -2
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +3 -3
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +2 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +7 -5
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +21 -19
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +5 -5
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +5 -5
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +8 -7
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +9 -9
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +68 -13
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +7 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +4 -0
- data/src/core/lib/security/credentials/tls/tls_utils.cc +32 -0
- data/src/core/lib/security/credentials/tls/tls_utils.h +13 -0
- data/src/core/lib/security/credentials/xds/xds_credentials.cc +3 -3
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +13 -3
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +13 -3
- data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +2 -2
- data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +12 -2
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +1 -1
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +22 -9
- data/src/core/lib/security/security_connector/security_connector.h +9 -4
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +16 -6
- data/src/core/lib/security/security_connector/ssl_utils.cc +27 -4
- data/src/core/lib/security/security_connector/ssl_utils.h +4 -4
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +60 -76
- data/src/core/lib/security/security_connector/tls/tls_security_connector.h +66 -48
- data/src/core/lib/security/transport/client_auth_filter.cc +18 -10
- data/src/core/lib/security/transport/secure_endpoint.cc +4 -4
- data/src/core/lib/security/transport/security_handshaker.cc +45 -36
- data/src/core/lib/security/transport/server_auth_filter.cc +17 -18
- data/src/core/lib/security/transport/tsi_error.cc +2 -1
- data/src/core/lib/security/transport/tsi_error.h +2 -1
- data/src/core/lib/security/util/json_util.cc +2 -2
- data/src/core/lib/security/util/json_util.h +1 -1
- data/src/core/lib/slice/slice_internal.h +1 -0
- data/src/core/lib/surface/call.cc +72 -52
- data/src/core/lib/surface/call.h +13 -2
- data/src/core/lib/surface/channel.cc +6 -6
- data/src/core/lib/surface/channel.h +3 -2
- data/src/core/lib/surface/channel_ping.cc +1 -1
- data/src/core/lib/surface/completion_queue.cc +68 -69
- data/src/core/lib/surface/completion_queue.h +3 -2
- data/src/core/lib/surface/completion_queue_factory.cc +1 -2
- data/src/core/lib/surface/init.cc +1 -3
- data/src/core/lib/surface/init.h +10 -1
- data/src/core/lib/surface/lame_client.cc +11 -11
- data/src/core/lib/surface/lame_client.h +1 -1
- data/src/core/lib/surface/server.cc +31 -23
- data/src/core/lib/surface/server.h +19 -18
- data/src/core/lib/surface/validate_metadata.cc +7 -7
- data/src/core/lib/surface/validate_metadata.h +3 -2
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/byte_stream.cc +5 -5
- data/src/core/lib/transport/byte_stream.h +8 -8
- data/src/core/lib/transport/connectivity_state.cc +1 -1
- data/src/core/lib/transport/error_utils.cc +21 -10
- data/src/core/lib/transport/error_utils.h +11 -5
- data/src/core/lib/transport/metadata_batch.cc +37 -37
- data/src/core/lib/transport/metadata_batch.h +19 -18
- data/src/core/lib/transport/transport.cc +4 -3
- data/src/core/lib/transport/transport.h +6 -4
- data/src/core/lib/transport/transport_op_string.cc +6 -6
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
- data/src/core/tsi/alts/crypt/gsec.h +6 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +5 -4
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +7 -6
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +2 -1
- data/src/core/tsi/ssl_transport_security.cc +32 -14
- data/src/core/tsi/ssl_transport_security.h +3 -4
- data/src/ruby/bin/math_services_pb.rb +1 -1
- data/src/ruby/ext/grpc/extconf.rb +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +11 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +1 -1
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +6 -6
- data/third_party/abseil-cpp/absl/algorithm/container.h +3 -3
- data/third_party/abseil-cpp/absl/base/attributes.h +24 -4
- data/third_party/abseil-cpp/absl/base/call_once.h +2 -9
- data/third_party/abseil-cpp/absl/base/config.h +37 -9
- data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +24 -10
- data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +4 -1
- data/third_party/abseil-cpp/absl/base/internal/endian.h +61 -0
- data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +2 -3
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +34 -32
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +16 -6
- data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +11 -2
- data/third_party/abseil-cpp/absl/base/internal/spinlock.h +14 -5
- data/third_party/abseil-cpp/absl/base/internal/spinlock_akaros.inc +2 -2
- data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +3 -3
- data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +2 -2
- data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +11 -11
- data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +5 -5
- data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +1 -1
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +5 -2
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +43 -42
- data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +111 -7
- data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +0 -76
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +1 -3
- data/third_party/abseil-cpp/absl/base/log_severity.h +4 -4
- data/third_party/abseil-cpp/absl/base/macros.h +11 -0
- data/third_party/abseil-cpp/absl/base/optimization.h +10 -7
- data/third_party/abseil-cpp/absl/base/options.h +1 -1
- data/third_party/abseil-cpp/absl/base/port.h +0 -1
- data/third_party/abseil-cpp/absl/base/thread_annotations.h +1 -1
- data/third_party/abseil-cpp/absl/container/fixed_array.h +2 -2
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +5 -3
- data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +1 -1
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +5 -1
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +2 -1
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc +2 -1
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +141 -66
- data/third_party/abseil-cpp/absl/container/internal/layout.h +4 -4
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +14 -1
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +136 -136
- data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +16 -12
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +5 -2
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +3 -12
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +6 -1
- data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +3 -5
- data/third_party/abseil-cpp/absl/debugging/symbolize_darwin.inc +2 -2
- data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +2 -2
- data/third_party/abseil-cpp/absl/hash/internal/city.cc +15 -12
- data/third_party/abseil-cpp/absl/hash/internal/city.h +1 -19
- data/third_party/abseil-cpp/absl/hash/internal/hash.cc +25 -10
- data/third_party/abseil-cpp/absl/hash/internal/hash.h +86 -37
- data/third_party/abseil-cpp/absl/hash/internal/wyhash.cc +111 -0
- data/third_party/abseil-cpp/absl/hash/internal/wyhash.h +48 -0
- data/third_party/abseil-cpp/absl/meta/type_traits.h +16 -2
- data/third_party/abseil-cpp/absl/numeric/bits.h +177 -0
- data/third_party/abseil-cpp/absl/numeric/int128.cc +3 -3
- data/third_party/abseil-cpp/absl/numeric/internal/bits.h +358 -0
- data/third_party/abseil-cpp/absl/numeric/internal/representation.h +55 -0
- data/third_party/abseil-cpp/absl/status/internal/status_internal.h +18 -0
- data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +4 -7
- data/third_party/abseil-cpp/absl/status/status.cc +29 -22
- data/third_party/abseil-cpp/absl/status/status.h +81 -20
- data/third_party/abseil-cpp/absl/status/statusor.h +3 -3
- data/third_party/abseil-cpp/absl/strings/charconv.cc +5 -5
- data/third_party/abseil-cpp/absl/strings/cord.cc +326 -371
- data/third_party/abseil-cpp/absl/strings/cord.h +182 -64
- data/third_party/abseil-cpp/absl/strings/escaping.cc +4 -4
- data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +6 -6
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.cc +83 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +387 -17
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_flat.h +146 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.cc +897 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.h +589 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring_reader.h +114 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +15 -1
- data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +19 -4
- data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +36 -18
- data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +14 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +15 -40
- data/third_party/abseil-cpp/absl/strings/internal/string_constant.h +64 -0
- data/third_party/abseil-cpp/absl/strings/match.cc +6 -3
- data/third_party/abseil-cpp/absl/strings/match.h +16 -6
- data/third_party/abseil-cpp/absl/strings/numbers.cc +132 -4
- data/third_party/abseil-cpp/absl/strings/numbers.h +10 -10
- data/third_party/abseil-cpp/absl/strings/str_join.h +1 -1
- data/third_party/abseil-cpp/absl/strings/str_split.h +38 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/futex.h +154 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +2 -1
- data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +2 -2
- data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +4 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +1 -65
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +2 -6
- data/third_party/abseil-cpp/absl/synchronization/mutex.cc +71 -59
- data/third_party/abseil-cpp/absl/synchronization/mutex.h +79 -62
- data/third_party/abseil-cpp/absl/time/clock.cc +146 -130
- data/third_party/abseil-cpp/absl/time/clock.h +2 -2
- data/third_party/abseil-cpp/absl/time/duration.cc +3 -2
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +7 -11
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +7 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +4 -4
- data/third_party/abseil-cpp/absl/time/time.cc +4 -3
- data/third_party/abseil-cpp/absl/time/time.h +26 -24
- data/third_party/abseil-cpp/absl/types/internal/variant.h +1 -1
- data/third_party/abseil-cpp/absl/types/variant.h +9 -4
- data/third_party/boringssl-with-bazel/err_data.c +483 -461
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +9 -7
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +18 -8
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +1 -2
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_locl.h +5 -0
- 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/cipher_extra/cipher_extra.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +1 -88
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +14 -3
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +119 -273
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/err/err.c +87 -80
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +9 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +0 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +11 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +25 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +7 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.c +10 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +87 -160
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +0 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +104 -93
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/internal.h +39 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +52 -65
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +52 -66
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +33 -22
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cfb.c +9 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +9 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +17 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +1 -22
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +2 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +1 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +0 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +26 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +26 -24
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/fips.c +79 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +14 -9
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +61 -75
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +80 -103
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +40 -49
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +367 -315
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +65 -0
- data/third_party/boringssl-with-bazel/src/crypto/mem.c +14 -0
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +5 -3
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +95 -48
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/rand_extra.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +1 -2
- data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +0 -28
- data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +120 -11
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_req.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +19 -25
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +3 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +42 -89
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +9 -16
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +14 -15
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +53 -73
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +31 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c +21 -17
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +7 -25
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +5 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +25 -22
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +5 -8
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +5 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_val.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +7 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +2 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -8
- data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +1 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +66 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +120 -41
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +47 -7
- data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +1 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +0 -8
- data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +24 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +6 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +5 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +33 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/err.h +3 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +20 -49
- data/third_party/boringssl-with-bazel/src/{crypto/x509/x509_r2x.c → include/openssl/evp_errors.h} +41 -58
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +325 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/obj.h +24 -5
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +25 -7
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +9 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +2 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +99 -63
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +283 -85
- data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +13 -19
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +445 -152
- data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +451 -435
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +2 -1
- data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +7 -2
- data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +1 -1
- data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +1133 -0
- data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +298 -22
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +66 -30
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +189 -86
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +154 -24
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +414 -135
- data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +9 -3
- data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +14 -19
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +4 -6
- data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +23 -26
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +51 -60
- data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +2 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +8 -31
- data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +3 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +4 -3
- data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +7 -3
- data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +664 -702
- data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +65 -7
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +98 -39
- data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +141 -94
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +213 -118
- data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +4 -2
- data/third_party/xxhash/xxhash.h +77 -195
- metadata +116 -51
- data/src/core/lib/gpr/arena.h +0 -47
- data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +0 -88
- data/src/core/lib/iomgr/poller/eventmanager_libuv.h +0 -88
- data/third_party/abseil-cpp/absl/base/internal/bits.h +0 -219
- data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +0 -249
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/is_fips.c +0 -29
- data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +0 -246
- data/third_party/boringssl-with-bazel/src/crypto/x509/vpm_int.h +0 -71
@@ -39,12 +39,12 @@ void grpc_chttp2_add_rst_stream_to_next_write(
|
|
39
39
|
grpc_chttp2_transport* t, uint32_t id, uint32_t code,
|
40
40
|
grpc_transport_one_way_stats* stats);
|
41
41
|
|
42
|
-
|
42
|
+
grpc_error_handle grpc_chttp2_rst_stream_parser_begin_frame(
|
43
43
|
grpc_chttp2_rst_stream_parser* parser, uint32_t length, uint8_t flags);
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
grpc_error_handle grpc_chttp2_rst_stream_parser_parse(void* parser,
|
45
|
+
grpc_chttp2_transport* t,
|
46
|
+
grpc_chttp2_stream* s,
|
47
|
+
const grpc_slice& slice,
|
48
|
+
int is_last);
|
49
49
|
|
50
50
|
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H */
|
@@ -84,7 +84,7 @@ grpc_slice grpc_chttp2_settings_ack_create(void) {
|
|
84
84
|
return output;
|
85
85
|
}
|
86
86
|
|
87
|
-
|
87
|
+
grpc_error_handle grpc_chttp2_settings_parser_begin_frame(
|
88
88
|
grpc_chttp2_settings_parser* parser, uint32_t length, uint8_t flags,
|
89
89
|
uint32_t* settings) {
|
90
90
|
parser->target_settings = settings;
|
@@ -110,10 +110,11 @@ grpc_error* grpc_chttp2_settings_parser_begin_frame(
|
|
110
110
|
}
|
111
111
|
}
|
112
112
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
113
|
+
grpc_error_handle grpc_chttp2_settings_parser_parse(void* p,
|
114
|
+
grpc_chttp2_transport* t,
|
115
|
+
grpc_chttp2_stream* /*s*/,
|
116
|
+
const grpc_slice& slice,
|
117
|
+
int is_last) {
|
117
118
|
grpc_chttp2_settings_parser* parser =
|
118
119
|
static_cast<grpc_chttp2_settings_parser*>(p);
|
119
120
|
const uint8_t* cur = GRPC_SLICE_START_PTR(slice);
|
@@ -145,7 +146,7 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t,
|
|
145
146
|
}
|
146
147
|
parser->id = static_cast<uint16_t>((static_cast<uint16_t>(*cur)) << 8);
|
147
148
|
cur++;
|
148
|
-
|
149
|
+
ABSL_FALLTHROUGH_INTENDED;
|
149
150
|
case GRPC_CHTTP2_SPS_ID1:
|
150
151
|
if (cur == end) {
|
151
152
|
parser->state = GRPC_CHTTP2_SPS_ID1;
|
@@ -153,7 +154,7 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t,
|
|
153
154
|
}
|
154
155
|
parser->id = static_cast<uint16_t>(parser->id | (*cur));
|
155
156
|
cur++;
|
156
|
-
|
157
|
+
ABSL_FALLTHROUGH_INTENDED;
|
157
158
|
case GRPC_CHTTP2_SPS_VAL0:
|
158
159
|
if (cur == end) {
|
159
160
|
parser->state = GRPC_CHTTP2_SPS_VAL0;
|
@@ -161,7 +162,7 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t,
|
|
161
162
|
}
|
162
163
|
parser->value = (static_cast<uint32_t>(*cur)) << 24;
|
163
164
|
cur++;
|
164
|
-
|
165
|
+
ABSL_FALLTHROUGH_INTENDED;
|
165
166
|
case GRPC_CHTTP2_SPS_VAL1:
|
166
167
|
if (cur == end) {
|
167
168
|
parser->state = GRPC_CHTTP2_SPS_VAL1;
|
@@ -169,7 +170,7 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t,
|
|
169
170
|
}
|
170
171
|
parser->value |= (static_cast<uint32_t>(*cur)) << 16;
|
171
172
|
cur++;
|
172
|
-
|
173
|
+
ABSL_FALLTHROUGH_INTENDED;
|
173
174
|
case GRPC_CHTTP2_SPS_VAL2:
|
174
175
|
if (cur == end) {
|
175
176
|
parser->state = GRPC_CHTTP2_SPS_VAL2;
|
@@ -177,7 +178,7 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t,
|
|
177
178
|
}
|
178
179
|
parser->value |= (static_cast<uint32_t>(*cur)) << 8;
|
179
180
|
cur++;
|
180
|
-
|
181
|
+
ABSL_FALLTHROUGH_INTENDED;
|
181
182
|
case GRPC_CHTTP2_SPS_VAL3:
|
182
183
|
if (cur == end) {
|
183
184
|
parser->state = GRPC_CHTTP2_SPS_VAL3;
|
@@ -49,13 +49,13 @@ grpc_slice grpc_chttp2_settings_create(uint32_t* old_settings,
|
|
49
49
|
/* Create an ack settings frame */
|
50
50
|
grpc_slice grpc_chttp2_settings_ack_create(void);
|
51
51
|
|
52
|
-
|
52
|
+
grpc_error_handle grpc_chttp2_settings_parser_begin_frame(
|
53
53
|
grpc_chttp2_settings_parser* parser, uint32_t length, uint8_t flags,
|
54
54
|
uint32_t* settings);
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
grpc_error_handle grpc_chttp2_settings_parser_parse(void* parser,
|
56
|
+
grpc_chttp2_transport* t,
|
57
|
+
grpc_chttp2_stream* s,
|
58
|
+
const grpc_slice& slice,
|
59
|
+
int is_last);
|
60
60
|
|
61
61
|
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H */
|
@@ -53,7 +53,7 @@ grpc_slice grpc_chttp2_window_update_create(
|
|
53
53
|
return slice;
|
54
54
|
}
|
55
55
|
|
56
|
-
|
56
|
+
grpc_error_handle grpc_chttp2_window_update_parser_begin_frame(
|
57
57
|
grpc_chttp2_window_update_parser* parser, uint32_t length, uint8_t flags) {
|
58
58
|
if (flags || length != 4) {
|
59
59
|
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
@@ -66,11 +66,9 @@ grpc_error* grpc_chttp2_window_update_parser_begin_frame(
|
|
66
66
|
return GRPC_ERROR_NONE;
|
67
67
|
}
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
const grpc_slice& slice,
|
73
|
-
int is_last) {
|
69
|
+
grpc_error_handle grpc_chttp2_window_update_parser_parse(
|
70
|
+
void* parser, grpc_chttp2_transport* t, grpc_chttp2_stream* s,
|
71
|
+
const grpc_slice& slice, int is_last) {
|
74
72
|
const uint8_t* const beg = GRPC_SLICE_START_PTR(slice);
|
75
73
|
const uint8_t* const end = GRPC_SLICE_END_PTR(slice);
|
76
74
|
const uint8_t* cur = beg;
|
@@ -33,12 +33,10 @@ struct grpc_chttp2_window_update_parser {
|
|
33
33
|
grpc_slice grpc_chttp2_window_update_create(
|
34
34
|
uint32_t id, uint32_t window_delta, grpc_transport_one_way_stats* stats);
|
35
35
|
|
36
|
-
|
36
|
+
grpc_error_handle grpc_chttp2_window_update_parser_begin_frame(
|
37
37
|
grpc_chttp2_window_update_parser* parser, uint32_t length, uint8_t flags);
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
const grpc_slice& slice,
|
42
|
-
int is_last);
|
38
|
+
grpc_error_handle grpc_chttp2_window_update_parser_parse(
|
39
|
+
void* parser, grpc_chttp2_transport* t, grpc_chttp2_stream* s,
|
40
|
+
const grpc_slice& slice, int is_last);
|
43
41
|
|
44
42
|
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H */
|
@@ -40,17 +40,17 @@
|
|
40
40
|
#include "src/core/lib/surface/validate_metadata.h"
|
41
41
|
#include "src/core/lib/transport/http2_errors.h"
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
43
|
+
#if __cplusplus > 201103L
|
44
|
+
#define GRPC_HPACK_CONSTEXPR_FN constexpr
|
45
|
+
#define GRPC_HPACK_CONSTEXPR_VALUE constexpr
|
46
|
+
#else
|
47
|
+
#define GRPC_HPACK_CONSTEXPR_FN
|
48
|
+
#define GRPC_HPACK_CONSTEXPR_VALUE const
|
49
|
+
#endif
|
50
|
+
|
51
|
+
namespace grpc_core {
|
52
|
+
|
53
|
+
DebugOnlyTraceFlag grpc_trace_chttp2_hpack_parser(false, "chttp2_hpack_parser");
|
54
54
|
|
55
55
|
/* How parsing works:
|
56
56
|
|
@@ -66,173 +66,6 @@ typedef enum {
|
|
66
66
|
It's expected that most optimizing compilers will turn this code into
|
67
67
|
a set of indirect jumps, and so not waste stack space. */
|
68
68
|
|
69
|
-
/* forward declarations for parsing states */
|
70
|
-
static grpc_error* parse_begin(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
71
|
-
const uint8_t* end);
|
72
|
-
static grpc_error* parse_error(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
73
|
-
const uint8_t* end, grpc_error* error);
|
74
|
-
static grpc_error* still_parse_error(grpc_chttp2_hpack_parser* p,
|
75
|
-
const uint8_t* cur, const uint8_t* end);
|
76
|
-
static grpc_error* parse_illegal_op(grpc_chttp2_hpack_parser* p,
|
77
|
-
const uint8_t* cur, const uint8_t* end);
|
78
|
-
|
79
|
-
static grpc_error* parse_string_prefix(grpc_chttp2_hpack_parser* p,
|
80
|
-
const uint8_t* cur, const uint8_t* end);
|
81
|
-
static grpc_error* parse_key_string(grpc_chttp2_hpack_parser* p,
|
82
|
-
const uint8_t* cur, const uint8_t* end);
|
83
|
-
static grpc_error* parse_value_string_with_indexed_key(
|
84
|
-
grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end);
|
85
|
-
static grpc_error* parse_value_string_with_literal_key(
|
86
|
-
grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end);
|
87
|
-
|
88
|
-
static grpc_error* parse_value0(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
89
|
-
const uint8_t* end);
|
90
|
-
static grpc_error* parse_value1(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
91
|
-
const uint8_t* end);
|
92
|
-
static grpc_error* parse_value2(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
93
|
-
const uint8_t* end);
|
94
|
-
static grpc_error* parse_value3(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
95
|
-
const uint8_t* end);
|
96
|
-
static grpc_error* parse_value4(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
97
|
-
const uint8_t* end);
|
98
|
-
static grpc_error* parse_value5up(grpc_chttp2_hpack_parser* p,
|
99
|
-
const uint8_t* cur, const uint8_t* end);
|
100
|
-
|
101
|
-
static grpc_error* parse_indexed_field(grpc_chttp2_hpack_parser* p,
|
102
|
-
const uint8_t* cur, const uint8_t* end);
|
103
|
-
static grpc_error* parse_indexed_field_x(grpc_chttp2_hpack_parser* p,
|
104
|
-
const uint8_t* cur,
|
105
|
-
const uint8_t* end);
|
106
|
-
static grpc_error* parse_lithdr_incidx(grpc_chttp2_hpack_parser* p,
|
107
|
-
const uint8_t* cur, const uint8_t* end);
|
108
|
-
static grpc_error* parse_lithdr_incidx_x(grpc_chttp2_hpack_parser* p,
|
109
|
-
const uint8_t* cur,
|
110
|
-
const uint8_t* end);
|
111
|
-
static grpc_error* parse_lithdr_incidx_v(grpc_chttp2_hpack_parser* p,
|
112
|
-
const uint8_t* cur,
|
113
|
-
const uint8_t* end);
|
114
|
-
static grpc_error* parse_lithdr_notidx(grpc_chttp2_hpack_parser* p,
|
115
|
-
const uint8_t* cur, const uint8_t* end);
|
116
|
-
static grpc_error* parse_lithdr_notidx_x(grpc_chttp2_hpack_parser* p,
|
117
|
-
const uint8_t* cur,
|
118
|
-
const uint8_t* end);
|
119
|
-
static grpc_error* parse_lithdr_notidx_v(grpc_chttp2_hpack_parser* p,
|
120
|
-
const uint8_t* cur,
|
121
|
-
const uint8_t* end);
|
122
|
-
static grpc_error* parse_lithdr_nvridx(grpc_chttp2_hpack_parser* p,
|
123
|
-
const uint8_t* cur, const uint8_t* end);
|
124
|
-
static grpc_error* parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser* p,
|
125
|
-
const uint8_t* cur,
|
126
|
-
const uint8_t* end);
|
127
|
-
static grpc_error* parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser* p,
|
128
|
-
const uint8_t* cur,
|
129
|
-
const uint8_t* end);
|
130
|
-
static grpc_error* parse_max_tbl_size(grpc_chttp2_hpack_parser* p,
|
131
|
-
const uint8_t* cur, const uint8_t* end);
|
132
|
-
static grpc_error* parse_max_tbl_size_x(grpc_chttp2_hpack_parser* p,
|
133
|
-
const uint8_t* cur, const uint8_t* end);
|
134
|
-
|
135
|
-
/* we translate the first byte of a hpack field into one of these decoding
|
136
|
-
cases, then use a lookup table to jump directly to the appropriate parser.
|
137
|
-
|
138
|
-
_X => the integer index is all ones, meaning we need to do varint decoding
|
139
|
-
_V => the integer index is all zeros, meaning we need to decode an additional
|
140
|
-
string value */
|
141
|
-
typedef enum {
|
142
|
-
INDEXED_FIELD,
|
143
|
-
INDEXED_FIELD_X,
|
144
|
-
LITHDR_INCIDX,
|
145
|
-
LITHDR_INCIDX_X,
|
146
|
-
LITHDR_INCIDX_V,
|
147
|
-
LITHDR_NOTIDX,
|
148
|
-
LITHDR_NOTIDX_X,
|
149
|
-
LITHDR_NOTIDX_V,
|
150
|
-
LITHDR_NVRIDX,
|
151
|
-
LITHDR_NVRIDX_X,
|
152
|
-
LITHDR_NVRIDX_V,
|
153
|
-
MAX_TBL_SIZE,
|
154
|
-
MAX_TBL_SIZE_X,
|
155
|
-
ILLEGAL
|
156
|
-
} first_byte_type;
|
157
|
-
|
158
|
-
/* jump table of parse state functions -- order must match first_byte_type
|
159
|
-
above */
|
160
|
-
static const grpc_chttp2_hpack_parser_state first_byte_action[] = {
|
161
|
-
parse_indexed_field, parse_indexed_field_x, parse_lithdr_incidx,
|
162
|
-
parse_lithdr_incidx_x, parse_lithdr_incidx_v, parse_lithdr_notidx,
|
163
|
-
parse_lithdr_notidx_x, parse_lithdr_notidx_v, parse_lithdr_nvridx,
|
164
|
-
parse_lithdr_nvridx_x, parse_lithdr_nvridx_v, parse_max_tbl_size,
|
165
|
-
parse_max_tbl_size_x, parse_illegal_op};
|
166
|
-
|
167
|
-
/* indexes the first byte to a parse state function - generated by
|
168
|
-
gen_hpack_tables.c */
|
169
|
-
static const uint8_t first_byte_lut[256] = {
|
170
|
-
LITHDR_NOTIDX_V, LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX,
|
171
|
-
LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX,
|
172
|
-
LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX,
|
173
|
-
LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX_X,
|
174
|
-
LITHDR_NVRIDX_V, LITHDR_NVRIDX, LITHDR_NVRIDX, LITHDR_NVRIDX,
|
175
|
-
LITHDR_NVRIDX, LITHDR_NVRIDX, LITHDR_NVRIDX, LITHDR_NVRIDX,
|
176
|
-
LITHDR_NVRIDX, LITHDR_NVRIDX, LITHDR_NVRIDX, LITHDR_NVRIDX,
|
177
|
-
LITHDR_NVRIDX, LITHDR_NVRIDX, LITHDR_NVRIDX, LITHDR_NVRIDX_X,
|
178
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE,
|
179
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE,
|
180
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE,
|
181
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE,
|
182
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE,
|
183
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE,
|
184
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE,
|
185
|
-
MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE, MAX_TBL_SIZE_X,
|
186
|
-
LITHDR_INCIDX_V, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
187
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
188
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
189
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
190
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
191
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
192
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
193
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
194
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
195
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
196
|
-
LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX, LITHDR_INCIDX,
|
197
|
-
LITHDR_INCIDX, 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_X,
|
202
|
-
ILLEGAL, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
203
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
204
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
205
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
206
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
207
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
208
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
209
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
210
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
211
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
212
|
-
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
|
213
|
-
INDEXED_FIELD, 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_X,
|
234
|
-
};
|
235
|
-
|
236
69
|
/* state table for huffman decoding: given a state, gives an index/16 into
|
237
70
|
next_sub_tbl. Taking that index and adding the value of the nibble being
|
238
71
|
considered returns the next state.
|
@@ -606,28 +439,37 @@ static const int16_t emit_sub_tbl[249 * 16] = {
|
|
606
439
|
13, 22, 22, 22, 22, 256, 256, 256, 256,
|
607
440
|
};
|
608
441
|
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
442
|
+
namespace {
|
443
|
+
// The alphabet used for base64 encoding binary metadata.
|
444
|
+
static constexpr char kBase64Alphabet[] =
|
445
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
446
|
+
|
447
|
+
// An inverted table: for each value in kBase64Alphabet, table contains the
|
448
|
+
// index with which it's stored, so we can quickly invert the encoding without
|
449
|
+
// any complicated runtime logic.
|
450
|
+
struct Base64InverseTable {
|
451
|
+
uint8_t table[256]{};
|
452
|
+
GRPC_HPACK_CONSTEXPR_FN Base64InverseTable() {
|
453
|
+
for (int i = 0; i < 256; i++) {
|
454
|
+
table[i] = 255;
|
455
|
+
}
|
456
|
+
for (const char* p = kBase64Alphabet; *p; p++) {
|
457
|
+
uint8_t idx = *p;
|
458
|
+
uint8_t ofs = p - kBase64Alphabet;
|
459
|
+
table[idx] = ofs;
|
460
|
+
}
|
461
|
+
}
|
628
462
|
};
|
629
463
|
|
630
|
-
static
|
464
|
+
static GRPC_HPACK_CONSTEXPR_VALUE Base64InverseTable kBase64InverseTable;
|
465
|
+
} // namespace
|
466
|
+
|
467
|
+
void HPackParser::FinishFrame() {
|
468
|
+
sink_ = Sink();
|
469
|
+
dynamic_table_updates_allowed_ = 2;
|
470
|
+
}
|
471
|
+
|
472
|
+
void GPR_ATTRIBUTE_NOINLINE HPackParser::LogHeader(grpc_mdelem md) {
|
631
473
|
char* k = grpc_slice_to_c_string(GRPC_MDKEY(md));
|
632
474
|
char* v = nullptr;
|
633
475
|
if (grpc_is_binary_header_internal(GRPC_MDKEY(md))) {
|
@@ -646,179 +488,270 @@ static void GPR_ATTRIBUTE_NOINLINE on_hdr_log(grpc_mdelem md) {
|
|
646
488
|
}
|
647
489
|
|
648
490
|
/* emission helpers */
|
649
|
-
template <
|
650
|
-
|
491
|
+
template <HPackParser::TableAction action>
|
492
|
+
grpc_error_handle HPackParser::FinishHeader(grpc_mdelem md) {
|
651
493
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) {
|
652
|
-
|
494
|
+
LogHeader(md);
|
653
495
|
}
|
654
|
-
if (
|
496
|
+
if (action == TableAction::kAddToTable) {
|
655
497
|
GPR_DEBUG_ASSERT(GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_INTERNED ||
|
656
498
|
GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC);
|
657
|
-
|
499
|
+
grpc_error_handle err = grpc_chttp2_hptbl_add(&table_, md);
|
658
500
|
if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) return err;
|
659
501
|
}
|
660
|
-
return
|
502
|
+
return sink_(md);
|
661
503
|
}
|
662
504
|
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
str->data.referenced = grpc_core::UnmanagedMemorySlice();
|
505
|
+
UnmanagedMemorySlice HPackParser::String::TakeExtern() {
|
506
|
+
UnmanagedMemorySlice s;
|
507
|
+
if (!copied_) {
|
508
|
+
GPR_DEBUG_ASSERT(!grpc_slice_is_interned(data_.referenced));
|
509
|
+
s = static_cast<UnmanagedMemorySlice&>(data_.referenced);
|
510
|
+
copied_ = true;
|
511
|
+
data_.referenced = UnmanagedMemorySlice();
|
671
512
|
} else {
|
672
|
-
s =
|
673
|
-
str->data.copied.length);
|
513
|
+
s = UnmanagedMemorySlice(data_.copied.str, data_.copied.length);
|
674
514
|
}
|
675
|
-
|
515
|
+
data_.copied.length = 0;
|
676
516
|
return s;
|
677
517
|
}
|
678
518
|
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
str->data.referenced = grpc_empty_slice();
|
519
|
+
ManagedMemorySlice HPackParser::String::TakeIntern() {
|
520
|
+
ManagedMemorySlice s;
|
521
|
+
if (!copied_) {
|
522
|
+
s = ManagedMemorySlice(&data_.referenced);
|
523
|
+
grpc_slice_unref_internal(data_.referenced);
|
524
|
+
copied_ = true;
|
525
|
+
data_.referenced = grpc_empty_slice();
|
687
526
|
} else {
|
688
|
-
s =
|
689
|
-
str->data.copied.length);
|
527
|
+
s = ManagedMemorySlice(data_.copied.str, data_.copied.length);
|
690
528
|
}
|
691
|
-
|
529
|
+
data_.copied.length = 0;
|
692
530
|
return s;
|
693
531
|
}
|
694
532
|
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
return p->state(p, cur, end);
|
533
|
+
grpc_error_handle HPackParser::parse_next(const uint8_t* cur,
|
534
|
+
const uint8_t* end) {
|
535
|
+
state_ = *next_state_++;
|
536
|
+
return (this->*state_)(cur, end);
|
700
537
|
}
|
701
538
|
|
702
539
|
/* begin parsing a header: all functionality is encoded into lookup tables
|
703
540
|
above */
|
704
|
-
|
705
|
-
|
541
|
+
grpc_error_handle HPackParser::parse_begin(const uint8_t* cur,
|
542
|
+
const uint8_t* end) {
|
706
543
|
if (cur == end) {
|
707
|
-
|
544
|
+
state_ = &HPackParser::parse_begin;
|
708
545
|
return GRPC_ERROR_NONE;
|
709
546
|
}
|
710
547
|
|
711
|
-
|
548
|
+
switch (*cur >> 4) {
|
549
|
+
// Literal header not indexed.
|
550
|
+
// First byte format: 0000xxxx
|
551
|
+
// Where xxxx:
|
552
|
+
// 0000 - literal key
|
553
|
+
// 1111 - indexed key, varint encoded index
|
554
|
+
// other - indexed key, inline encoded index
|
555
|
+
case 0:
|
556
|
+
switch (*cur & 0xf) {
|
557
|
+
case 0: // literal key
|
558
|
+
return parse_lithdr_notidx_v(cur, end);
|
559
|
+
case 0xf: // varint encoded key index
|
560
|
+
return parse_lithdr_notidx_x(cur, end);
|
561
|
+
default: // inline encoded key index
|
562
|
+
return parse_lithdr_notidx(cur, end);
|
563
|
+
}
|
564
|
+
// Literal header never indexed.
|
565
|
+
// First byte format: 0001xxxx
|
566
|
+
// Where xxxx:
|
567
|
+
// 0000 - literal key
|
568
|
+
// 1111 - indexed key, varint encoded index
|
569
|
+
// other - indexed key, inline encoded index
|
570
|
+
case 1:
|
571
|
+
switch (*cur & 0xf) {
|
572
|
+
case 0: // literal key
|
573
|
+
return parse_lithdr_nvridx_v(cur, end);
|
574
|
+
case 0xf: // varint encoded key index
|
575
|
+
return parse_lithdr_nvridx_x(cur, end);
|
576
|
+
default: // inline encoded key index
|
577
|
+
return parse_lithdr_nvridx(cur, end);
|
578
|
+
}
|
579
|
+
// Update max table size.
|
580
|
+
// First byte format: 001xxxxx
|
581
|
+
// Where xxxxx:
|
582
|
+
// 11111 - max size is varint encoded
|
583
|
+
// other - max size is stored inline
|
584
|
+
case 2:
|
585
|
+
// inline encoded max table size
|
586
|
+
return parse_max_tbl_size(cur, end);
|
587
|
+
case 3:
|
588
|
+
if (*cur == 0x3f) {
|
589
|
+
// varint encoded max table size
|
590
|
+
return parse_max_tbl_size_x(cur, end);
|
591
|
+
} else {
|
592
|
+
// inline encoded max table size
|
593
|
+
return parse_max_tbl_size(cur, end);
|
594
|
+
}
|
595
|
+
// Literal header with incremental indexing.
|
596
|
+
// First byte format: 01xxxxxx
|
597
|
+
// Where xxxxxx:
|
598
|
+
// 000000 - literal key
|
599
|
+
// 111111 - indexed key, varint encoded index
|
600
|
+
// other - indexed key, inline encoded index
|
601
|
+
case 4:
|
602
|
+
if (*cur == 0x40) {
|
603
|
+
// literal key
|
604
|
+
return parse_lithdr_incidx_v(cur, end);
|
605
|
+
}
|
606
|
+
ABSL_FALLTHROUGH_INTENDED;
|
607
|
+
case 5:
|
608
|
+
case 6:
|
609
|
+
// inline encoded key index
|
610
|
+
return parse_lithdr_incidx(cur, end);
|
611
|
+
case 7:
|
612
|
+
if (*cur == 0x7f) {
|
613
|
+
// varint encoded key index
|
614
|
+
return parse_lithdr_incidx_x(cur, end);
|
615
|
+
} else {
|
616
|
+
// inline encoded key index
|
617
|
+
return parse_lithdr_incidx(cur, end);
|
618
|
+
}
|
619
|
+
// Indexed Header Field Representation
|
620
|
+
// First byte format: 1xxxxxxx
|
621
|
+
// Where xxxxxxx:
|
622
|
+
// 0000000 - illegal
|
623
|
+
// 1111111 - varint encoded field index
|
624
|
+
// other - inline encoded field index
|
625
|
+
case 8:
|
626
|
+
if (*cur == 0x80) {
|
627
|
+
// illegal value.
|
628
|
+
return parse_illegal_op(cur, end);
|
629
|
+
}
|
630
|
+
ABSL_FALLTHROUGH_INTENDED;
|
631
|
+
case 9:
|
632
|
+
case 10:
|
633
|
+
case 11:
|
634
|
+
case 12:
|
635
|
+
case 13:
|
636
|
+
case 14:
|
637
|
+
// inline encoded field index
|
638
|
+
return parse_indexed_field(cur, end);
|
639
|
+
case 15:
|
640
|
+
if (*cur == 0xff) {
|
641
|
+
// varint encoded field index
|
642
|
+
return parse_indexed_field_x(cur, end);
|
643
|
+
} else {
|
644
|
+
// inline encoded field index
|
645
|
+
return parse_indexed_field(cur, end);
|
646
|
+
}
|
647
|
+
}
|
648
|
+
GPR_UNREACHABLE_CODE(abort());
|
712
649
|
}
|
713
650
|
|
714
651
|
/* stream dependency and prioritization data: we just skip it */
|
715
|
-
|
716
|
-
|
652
|
+
grpc_error_handle HPackParser::parse_stream_weight(const uint8_t* cur,
|
653
|
+
const uint8_t* end) {
|
717
654
|
if (cur == end) {
|
718
|
-
|
655
|
+
state_ = &HPackParser::parse_stream_weight;
|
719
656
|
return GRPC_ERROR_NONE;
|
720
657
|
}
|
721
658
|
|
722
|
-
return
|
659
|
+
return (this->*after_prioritization_)(cur + 1, end);
|
723
660
|
}
|
724
661
|
|
725
|
-
|
726
|
-
|
662
|
+
grpc_error_handle HPackParser::parse_stream_dep3(const uint8_t* cur,
|
663
|
+
const uint8_t* end) {
|
727
664
|
if (cur == end) {
|
728
|
-
|
665
|
+
state_ = &HPackParser::parse_stream_dep3;
|
729
666
|
return GRPC_ERROR_NONE;
|
730
667
|
}
|
731
668
|
|
732
|
-
return parse_stream_weight(
|
669
|
+
return parse_stream_weight(cur + 1, end);
|
733
670
|
}
|
734
671
|
|
735
|
-
|
736
|
-
|
672
|
+
grpc_error_handle HPackParser::parse_stream_dep2(const uint8_t* cur,
|
673
|
+
const uint8_t* end) {
|
737
674
|
if (cur == end) {
|
738
|
-
|
675
|
+
state_ = &HPackParser::parse_stream_dep2;
|
739
676
|
return GRPC_ERROR_NONE;
|
740
677
|
}
|
741
678
|
|
742
|
-
return parse_stream_dep3(
|
679
|
+
return parse_stream_dep3(cur + 1, end);
|
743
680
|
}
|
744
681
|
|
745
|
-
|
746
|
-
|
682
|
+
grpc_error_handle HPackParser::parse_stream_dep1(const uint8_t* cur,
|
683
|
+
const uint8_t* end) {
|
747
684
|
if (cur == end) {
|
748
|
-
|
685
|
+
state_ = &HPackParser::parse_stream_dep1;
|
749
686
|
return GRPC_ERROR_NONE;
|
750
687
|
}
|
751
688
|
|
752
|
-
return parse_stream_dep2(
|
689
|
+
return parse_stream_dep2(cur + 1, end);
|
753
690
|
}
|
754
691
|
|
755
|
-
|
756
|
-
|
692
|
+
grpc_error_handle HPackParser::parse_stream_dep0(const uint8_t* cur,
|
693
|
+
const uint8_t* end) {
|
757
694
|
if (cur == end) {
|
758
|
-
|
695
|
+
state_ = &HPackParser::parse_stream_dep0;
|
759
696
|
return GRPC_ERROR_NONE;
|
760
697
|
}
|
761
698
|
|
762
|
-
return parse_stream_dep1(
|
699
|
+
return parse_stream_dep1(cur + 1, end);
|
763
700
|
}
|
764
701
|
|
765
|
-
|
766
|
-
on_invalid_hpack_idx(grpc_chttp2_hpack_parser* p) {
|
702
|
+
grpc_error_handle HPackParser::InvalidHPackIndexError() {
|
767
703
|
return grpc_error_set_int(
|
768
704
|
grpc_error_set_int(
|
769
705
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid HPACK index received"),
|
770
|
-
GRPC_ERROR_INT_INDEX, static_cast<intptr_t>(
|
771
|
-
GRPC_ERROR_INT_SIZE, static_cast<intptr_t>(
|
706
|
+
GRPC_ERROR_INT_INDEX, static_cast<intptr_t>(index_)),
|
707
|
+
GRPC_ERROR_INT_SIZE, static_cast<intptr_t>(table_.num_ents));
|
772
708
|
}
|
773
709
|
|
774
710
|
/* emit an indexed field; jumps to begin the next field on completion */
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
grpc_mdelem md = grpc_chttp2_hptbl_lookup<true>(&p->table, p->index);
|
711
|
+
grpc_error_handle HPackParser::finish_indexed_field(const uint8_t* cur,
|
712
|
+
const uint8_t* end) {
|
713
|
+
grpc_mdelem md = grpc_chttp2_hptbl_lookup<true>(&table_, index_);
|
779
714
|
if (GPR_UNLIKELY(GRPC_MDISNULL(md))) {
|
780
|
-
return
|
715
|
+
return InvalidHPackIndexError();
|
781
716
|
}
|
782
717
|
GRPC_STATS_INC_HPACK_RECV_INDEXED();
|
783
|
-
|
718
|
+
grpc_error_handle err = FinishHeader<TableAction::kOmitFromTable>(md);
|
784
719
|
if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) return err;
|
785
|
-
return parse_begin(
|
720
|
+
return parse_begin(cur, end);
|
786
721
|
}
|
787
722
|
|
788
723
|
/* parse an indexed field with index < 127 */
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
return finish_indexed_field(
|
724
|
+
grpc_error_handle HPackParser::parse_indexed_field(const uint8_t* cur,
|
725
|
+
const uint8_t* end) {
|
726
|
+
dynamic_table_updates_allowed_ = 0;
|
727
|
+
index_ = (*cur) & 0x7f;
|
728
|
+
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
729
|
+
return finish_indexed_field(cur + 1, end);
|
795
730
|
}
|
796
731
|
|
797
732
|
/* parse an indexed field with index >= 127 */
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
p->parsing.value = &p->index;
|
808
|
-
return parse_value0(p, cur + 1, end);
|
733
|
+
grpc_error_handle HPackParser::parse_indexed_field_x(const uint8_t* cur,
|
734
|
+
const uint8_t* end) {
|
735
|
+
static const State and_then[] = {&HPackParser::finish_indexed_field};
|
736
|
+
dynamic_table_updates_allowed_ = 0;
|
737
|
+
next_state_ = and_then;
|
738
|
+
index_ = 0x7f;
|
739
|
+
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
740
|
+
parsing_.value = &index_;
|
741
|
+
return parse_value0(cur + 1, end);
|
809
742
|
}
|
810
743
|
|
811
744
|
/* When finishing with a header, get the cached md element for this index.
|
812
745
|
This is set in parse_value_string(). We ensure (in debug mode) that the
|
813
746
|
cached metadata corresponds with the index we are examining. */
|
814
|
-
|
815
|
-
GPR_DEBUG_ASSERT(
|
816
|
-
GPR_DEBUG_ASSERT(static_cast<int64_t>(
|
817
|
-
grpc_mdelem md =
|
747
|
+
grpc_mdelem HPackParser::GetPrecomputedMDForIndex() {
|
748
|
+
GPR_DEBUG_ASSERT(md_for_index_.payload != 0);
|
749
|
+
GPR_DEBUG_ASSERT(static_cast<int64_t>(index_) == precomputed_md_index_);
|
750
|
+
grpc_mdelem md = md_for_index_;
|
818
751
|
GPR_DEBUG_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */
|
819
|
-
|
752
|
+
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
820
753
|
#ifndef NDEBUG
|
821
|
-
|
754
|
+
precomputed_md_index_ = -1;
|
822
755
|
#endif
|
823
756
|
return md;
|
824
757
|
}
|
@@ -830,352 +763,340 @@ static const grpc_core::ManagedMemorySlice& get_indexed_key(grpc_mdelem md) {
|
|
830
763
|
}
|
831
764
|
|
832
765
|
/* finish a literal header with incremental indexing */
|
833
|
-
|
834
|
-
|
835
|
-
const uint8_t* end) {
|
766
|
+
grpc_error_handle HPackParser::finish_lithdr_incidx(const uint8_t* cur,
|
767
|
+
const uint8_t* end) {
|
836
768
|
GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX();
|
837
|
-
grpc_mdelem md =
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
return parse_begin(p, cur, end);
|
769
|
+
grpc_mdelem md = GetPrecomputedMDForIndex();
|
770
|
+
grpc_error_handle err = FinishHeader<TableAction::kAddToTable>(
|
771
|
+
grpc_mdelem_from_slices(get_indexed_key(md), value_.TakeIntern()));
|
772
|
+
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
773
|
+
return parse_begin(cur, end);
|
843
774
|
}
|
844
775
|
|
845
776
|
/* finish a literal header with incremental indexing with no index */
|
846
|
-
|
847
|
-
|
848
|
-
const uint8_t* end) {
|
777
|
+
grpc_error_handle HPackParser::finish_lithdr_incidx_v(const uint8_t* cur,
|
778
|
+
const uint8_t* end) {
|
849
779
|
GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V();
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
return parse_begin(p, cur, end);
|
780
|
+
grpc_error_handle err = FinishHeader<TableAction::kAddToTable>(
|
781
|
+
grpc_mdelem_from_slices(key_.TakeIntern(), value_.TakeIntern()));
|
782
|
+
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
783
|
+
return parse_begin(cur, end);
|
855
784
|
}
|
856
785
|
|
857
786
|
/* parse a literal header with incremental indexing; index < 63 */
|
858
|
-
|
859
|
-
|
860
|
-
static const
|
861
|
-
parse_value_string_with_indexed_key,
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
787
|
+
grpc_error_handle HPackParser::parse_lithdr_incidx(const uint8_t* cur,
|
788
|
+
const uint8_t* end) {
|
789
|
+
static const State and_then[] = {
|
790
|
+
&HPackParser::parse_value_string_with_indexed_key,
|
791
|
+
&HPackParser::finish_lithdr_incidx};
|
792
|
+
dynamic_table_updates_allowed_ = 0;
|
793
|
+
next_state_ = and_then;
|
794
|
+
index_ = (*cur) & 0x3f;
|
795
|
+
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
796
|
+
return parse_string_prefix(cur + 1, end);
|
867
797
|
}
|
868
798
|
|
869
799
|
/* parse a literal header with incremental indexing; index >= 63 */
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
finish_lithdr_incidx};
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
return parse_value0(
|
800
|
+
grpc_error_handle HPackParser::parse_lithdr_incidx_x(const uint8_t* cur,
|
801
|
+
const uint8_t* end) {
|
802
|
+
static const State and_then[] = {
|
803
|
+
&HPackParser::parse_string_prefix,
|
804
|
+
&HPackParser::parse_value_string_with_indexed_key,
|
805
|
+
&HPackParser::finish_lithdr_incidx};
|
806
|
+
dynamic_table_updates_allowed_ = 0;
|
807
|
+
next_state_ = and_then;
|
808
|
+
index_ = 0x3f;
|
809
|
+
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
810
|
+
parsing_.value = &index_;
|
811
|
+
return parse_value0(cur + 1, end);
|
882
812
|
}
|
883
813
|
|
884
814
|
/* parse a literal header with incremental indexing; index = 0 */
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
return parse_string_prefix(
|
815
|
+
grpc_error_handle HPackParser::parse_lithdr_incidx_v(const uint8_t* cur,
|
816
|
+
const uint8_t* end) {
|
817
|
+
static const State and_then[] = {
|
818
|
+
&HPackParser::parse_key_string, &HPackParser::parse_string_prefix,
|
819
|
+
&HPackParser::parse_value_string_with_literal_key,
|
820
|
+
&HPackParser::finish_lithdr_incidx_v};
|
821
|
+
dynamic_table_updates_allowed_ = 0;
|
822
|
+
next_state_ = and_then;
|
823
|
+
return parse_string_prefix(cur + 1, end);
|
894
824
|
}
|
895
825
|
|
896
826
|
/* finish a literal header without incremental indexing */
|
897
|
-
|
898
|
-
|
899
|
-
const uint8_t* end) {
|
827
|
+
grpc_error_handle HPackParser::finish_lithdr_notidx(const uint8_t* cur,
|
828
|
+
const uint8_t* end) {
|
900
829
|
GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX();
|
901
|
-
grpc_mdelem md =
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
return parse_begin(p, cur, end);
|
830
|
+
grpc_mdelem md = GetPrecomputedMDForIndex();
|
831
|
+
grpc_error_handle err = FinishHeader<TableAction::kOmitFromTable>(
|
832
|
+
grpc_mdelem_from_slices(get_indexed_key(md), value_.TakeExtern()));
|
833
|
+
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
834
|
+
return parse_begin(cur, end);
|
907
835
|
}
|
908
836
|
|
909
837
|
/* finish a literal header without incremental indexing with index = 0 */
|
910
|
-
|
911
|
-
|
912
|
-
const uint8_t* end) {
|
838
|
+
grpc_error_handle HPackParser::finish_lithdr_notidx_v(const uint8_t* cur,
|
839
|
+
const uint8_t* end) {
|
913
840
|
GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V();
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
return parse_begin(p, cur, end);
|
841
|
+
grpc_error_handle err = FinishHeader<TableAction::kOmitFromTable>(
|
842
|
+
grpc_mdelem_from_slices(key_.TakeIntern(), value_.TakeExtern()));
|
843
|
+
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
844
|
+
return parse_begin(cur, end);
|
919
845
|
}
|
920
846
|
|
921
847
|
/* parse a literal header without incremental indexing; index < 15 */
|
922
|
-
|
923
|
-
|
924
|
-
static const
|
925
|
-
parse_value_string_with_indexed_key,
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
848
|
+
grpc_error_handle HPackParser::parse_lithdr_notidx(const uint8_t* cur,
|
849
|
+
const uint8_t* end) {
|
850
|
+
static const State and_then[] = {
|
851
|
+
&HPackParser::parse_value_string_with_indexed_key,
|
852
|
+
&HPackParser::finish_lithdr_notidx};
|
853
|
+
dynamic_table_updates_allowed_ = 0;
|
854
|
+
next_state_ = and_then;
|
855
|
+
index_ = (*cur) & 0xf;
|
856
|
+
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
857
|
+
return parse_string_prefix(cur + 1, end);
|
931
858
|
}
|
932
859
|
|
933
860
|
/* parse a literal header without incremental indexing; index >= 15 */
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
finish_lithdr_notidx};
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
return parse_value0(
|
861
|
+
grpc_error_handle HPackParser::parse_lithdr_notidx_x(const uint8_t* cur,
|
862
|
+
const uint8_t* end) {
|
863
|
+
static const State and_then[] = {
|
864
|
+
&HPackParser::parse_string_prefix,
|
865
|
+
&HPackParser::parse_value_string_with_indexed_key,
|
866
|
+
&HPackParser::finish_lithdr_notidx};
|
867
|
+
dynamic_table_updates_allowed_ = 0;
|
868
|
+
next_state_ = and_then;
|
869
|
+
index_ = 0xf;
|
870
|
+
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
871
|
+
parsing_.value = &index_;
|
872
|
+
return parse_value0(cur + 1, end);
|
946
873
|
}
|
947
874
|
|
948
875
|
/* parse a literal header without incremental indexing; index == 0 */
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
return parse_string_prefix(
|
876
|
+
grpc_error_handle HPackParser::parse_lithdr_notidx_v(const uint8_t* cur,
|
877
|
+
const uint8_t* end) {
|
878
|
+
static const State and_then[] = {
|
879
|
+
&HPackParser::parse_key_string, &HPackParser::parse_string_prefix,
|
880
|
+
&HPackParser::parse_value_string_with_literal_key,
|
881
|
+
&HPackParser::finish_lithdr_notidx_v};
|
882
|
+
dynamic_table_updates_allowed_ = 0;
|
883
|
+
next_state_ = and_then;
|
884
|
+
return parse_string_prefix(cur + 1, end);
|
958
885
|
}
|
959
886
|
|
960
887
|
/* finish a literal header that is never indexed */
|
961
|
-
|
962
|
-
|
963
|
-
const uint8_t* end) {
|
888
|
+
grpc_error_handle HPackParser::finish_lithdr_nvridx(const uint8_t* cur,
|
889
|
+
const uint8_t* end) {
|
964
890
|
GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX();
|
965
|
-
grpc_mdelem md =
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
return parse_begin(p, cur, end);
|
891
|
+
grpc_mdelem md = GetPrecomputedMDForIndex();
|
892
|
+
grpc_error_handle err = FinishHeader<TableAction::kOmitFromTable>(
|
893
|
+
grpc_mdelem_from_slices(get_indexed_key(md), value_.TakeExtern()));
|
894
|
+
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
895
|
+
return parse_begin(cur, end);
|
971
896
|
}
|
972
897
|
|
973
898
|
/* finish a literal header that is never indexed with an extra value */
|
974
|
-
|
975
|
-
|
976
|
-
const uint8_t* end) {
|
899
|
+
grpc_error_handle HPackParser::finish_lithdr_nvridx_v(const uint8_t* cur,
|
900
|
+
const uint8_t* end) {
|
977
901
|
GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V();
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
return parse_begin(p, cur, end);
|
902
|
+
grpc_error_handle err = FinishHeader<TableAction::kOmitFromTable>(
|
903
|
+
grpc_mdelem_from_slices(key_.TakeIntern(), value_.TakeExtern()));
|
904
|
+
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
905
|
+
return parse_begin(cur, end);
|
983
906
|
}
|
984
907
|
|
985
908
|
/* parse a literal header that is never indexed; index < 15 */
|
986
|
-
|
987
|
-
|
988
|
-
static const
|
989
|
-
parse_value_string_with_indexed_key,
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
909
|
+
grpc_error_handle HPackParser::parse_lithdr_nvridx(const uint8_t* cur,
|
910
|
+
const uint8_t* end) {
|
911
|
+
static const State and_then[] = {
|
912
|
+
&HPackParser::parse_value_string_with_indexed_key,
|
913
|
+
&HPackParser::finish_lithdr_nvridx};
|
914
|
+
dynamic_table_updates_allowed_ = 0;
|
915
|
+
next_state_ = and_then;
|
916
|
+
index_ = (*cur) & 0xf;
|
917
|
+
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
918
|
+
return parse_string_prefix(cur + 1, end);
|
995
919
|
}
|
996
920
|
|
997
921
|
/* parse a literal header that is never indexed; index >= 15 */
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
finish_lithdr_nvridx};
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
return parse_value0(
|
922
|
+
grpc_error_handle HPackParser::parse_lithdr_nvridx_x(const uint8_t* cur,
|
923
|
+
const uint8_t* end) {
|
924
|
+
static const State and_then[] = {
|
925
|
+
&HPackParser::parse_string_prefix,
|
926
|
+
&HPackParser::parse_value_string_with_indexed_key,
|
927
|
+
&HPackParser::finish_lithdr_nvridx};
|
928
|
+
dynamic_table_updates_allowed_ = 0;
|
929
|
+
next_state_ = and_then;
|
930
|
+
index_ = 0xf;
|
931
|
+
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
932
|
+
parsing_.value = &index_;
|
933
|
+
return parse_value0(cur + 1, end);
|
1010
934
|
}
|
1011
935
|
|
1012
936
|
/* parse a literal header that is never indexed; index == 0 */
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
return parse_string_prefix(
|
937
|
+
grpc_error_handle HPackParser::parse_lithdr_nvridx_v(const uint8_t* cur,
|
938
|
+
const uint8_t* end) {
|
939
|
+
static const State and_then[] = {
|
940
|
+
&HPackParser::parse_key_string, &HPackParser::parse_string_prefix,
|
941
|
+
&HPackParser::parse_value_string_with_literal_key,
|
942
|
+
&HPackParser::finish_lithdr_nvridx_v};
|
943
|
+
dynamic_table_updates_allowed_ = 0;
|
944
|
+
next_state_ = and_then;
|
945
|
+
return parse_string_prefix(cur + 1, end);
|
1022
946
|
}
|
1023
947
|
|
1024
948
|
/* finish parsing a max table size change */
|
1025
|
-
|
1026
|
-
|
949
|
+
grpc_error_handle HPackParser::finish_max_tbl_size(const uint8_t* cur,
|
950
|
+
const uint8_t* end) {
|
1027
951
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) {
|
1028
|
-
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d",
|
952
|
+
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", index_);
|
1029
953
|
}
|
1030
|
-
|
1031
|
-
grpc_chttp2_hptbl_set_current_table_size(&
|
1032
|
-
if (err != GRPC_ERROR_NONE) return parse_error(
|
1033
|
-
return parse_begin(
|
954
|
+
grpc_error_handle err =
|
955
|
+
grpc_chttp2_hptbl_set_current_table_size(&table_, index_);
|
956
|
+
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
957
|
+
return parse_begin(cur, end);
|
1034
958
|
}
|
1035
959
|
|
1036
960
|
/* parse a max table size change, max size < 15 */
|
1037
|
-
|
1038
|
-
|
1039
|
-
if (
|
961
|
+
grpc_error_handle HPackParser::parse_max_tbl_size(const uint8_t* cur,
|
962
|
+
const uint8_t* end) {
|
963
|
+
if (dynamic_table_updates_allowed_ == 0) {
|
1040
964
|
return parse_error(
|
1041
|
-
|
965
|
+
cur, end,
|
1042
966
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1043
967
|
"More than two max table size changes in a single frame"));
|
1044
968
|
}
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
return finish_max_tbl_size(
|
969
|
+
dynamic_table_updates_allowed_--;
|
970
|
+
index_ = (*cur) & 0x1f;
|
971
|
+
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
972
|
+
return finish_max_tbl_size(cur + 1, end);
|
1049
973
|
}
|
1050
974
|
|
1051
975
|
/* parse a max table size change, max size >= 15 */
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
finish_max_tbl_size};
|
1057
|
-
if (p->dynamic_table_update_allowed == 0) {
|
976
|
+
grpc_error_handle HPackParser::parse_max_tbl_size_x(const uint8_t* cur,
|
977
|
+
const uint8_t* end) {
|
978
|
+
static const State and_then[] = {&HPackParser::finish_max_tbl_size};
|
979
|
+
if (dynamic_table_updates_allowed_ == 0) {
|
1058
980
|
return parse_error(
|
1059
|
-
|
981
|
+
cur, end,
|
1060
982
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1061
983
|
"More than two max table size changes in a single frame"));
|
1062
984
|
}
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
return parse_value0(
|
985
|
+
dynamic_table_updates_allowed_--;
|
986
|
+
next_state_ = and_then;
|
987
|
+
index_ = 0x1f;
|
988
|
+
md_for_index_.payload = 0; /* Invalidate cached md when index changes. */
|
989
|
+
parsing_.value = &index_;
|
990
|
+
return parse_value0(cur + 1, end);
|
1069
991
|
}
|
1070
992
|
|
1071
993
|
/* a parse error: jam the parse state into parse_error, and return error */
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
994
|
+
grpc_error_handle HPackParser::parse_error(const uint8_t* /*cur*/,
|
995
|
+
const uint8_t* /*end*/,
|
996
|
+
grpc_error_handle err) {
|
1075
997
|
GPR_ASSERT(err != GRPC_ERROR_NONE);
|
1076
|
-
if (
|
1077
|
-
|
998
|
+
if (last_error_ == GRPC_ERROR_NONE) {
|
999
|
+
last_error_ = GRPC_ERROR_REF(err);
|
1078
1000
|
}
|
1079
|
-
|
1001
|
+
state_ = &HPackParser::still_parse_error;
|
1080
1002
|
return err;
|
1081
1003
|
}
|
1082
1004
|
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
return GRPC_ERROR_REF(p->last_error);
|
1005
|
+
grpc_error_handle HPackParser::still_parse_error(const uint8_t* /*cur*/,
|
1006
|
+
const uint8_t* /*end*/) {
|
1007
|
+
return GRPC_ERROR_REF(last_error_);
|
1087
1008
|
}
|
1088
1009
|
|
1089
|
-
|
1090
|
-
|
1010
|
+
grpc_error_handle HPackParser::parse_illegal_op(const uint8_t* cur,
|
1011
|
+
const uint8_t* end) {
|
1091
1012
|
GPR_ASSERT(cur != end);
|
1092
|
-
|
1013
|
+
grpc_error_handle err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1093
1014
|
absl::StrCat("Illegal hpack op code ", *cur).c_str());
|
1094
|
-
return parse_error(
|
1015
|
+
return parse_error(cur, end, err);
|
1095
1016
|
}
|
1096
1017
|
|
1097
|
-
/* parse the 1st byte of a varint into
|
1018
|
+
/* parse the 1st byte of a varint into parsing_.value
|
1098
1019
|
no overflow is possible */
|
1099
|
-
|
1100
|
-
|
1020
|
+
grpc_error_handle HPackParser::parse_value0(const uint8_t* cur,
|
1021
|
+
const uint8_t* end) {
|
1101
1022
|
if (cur == end) {
|
1102
|
-
|
1023
|
+
state_ = &HPackParser::parse_value0;
|
1103
1024
|
return GRPC_ERROR_NONE;
|
1104
1025
|
}
|
1105
1026
|
|
1106
|
-
*
|
1027
|
+
*parsing_.value += (*cur) & 0x7f;
|
1107
1028
|
|
1108
1029
|
if ((*cur) & 0x80) {
|
1109
|
-
return parse_value1(
|
1030
|
+
return parse_value1(cur + 1, end);
|
1110
1031
|
} else {
|
1111
|
-
return parse_next(
|
1032
|
+
return parse_next(cur + 1, end);
|
1112
1033
|
}
|
1113
1034
|
}
|
1114
1035
|
|
1115
|
-
/* parse the 2nd byte of a varint into
|
1036
|
+
/* parse the 2nd byte of a varint into parsing_.value
|
1116
1037
|
no overflow is possible */
|
1117
|
-
|
1118
|
-
|
1038
|
+
grpc_error_handle HPackParser::parse_value1(const uint8_t* cur,
|
1039
|
+
const uint8_t* end) {
|
1119
1040
|
if (cur == end) {
|
1120
|
-
|
1041
|
+
state_ = &HPackParser::parse_value1;
|
1121
1042
|
return GRPC_ERROR_NONE;
|
1122
1043
|
}
|
1123
1044
|
|
1124
|
-
*
|
1045
|
+
*parsing_.value += ((static_cast<uint32_t>(*cur)) & 0x7f) << 7;
|
1125
1046
|
|
1126
1047
|
if ((*cur) & 0x80) {
|
1127
|
-
return parse_value2(
|
1048
|
+
return parse_value2(cur + 1, end);
|
1128
1049
|
} else {
|
1129
|
-
return parse_next(
|
1050
|
+
return parse_next(cur + 1, end);
|
1130
1051
|
}
|
1131
1052
|
}
|
1132
1053
|
|
1133
|
-
/* parse the 3rd byte of a varint into
|
1054
|
+
/* parse the 3rd byte of a varint into parsing_.value
|
1134
1055
|
no overflow is possible */
|
1135
|
-
|
1136
|
-
|
1056
|
+
grpc_error_handle HPackParser::parse_value2(const uint8_t* cur,
|
1057
|
+
const uint8_t* end) {
|
1137
1058
|
if (cur == end) {
|
1138
|
-
|
1059
|
+
state_ = &HPackParser::parse_value2;
|
1139
1060
|
return GRPC_ERROR_NONE;
|
1140
1061
|
}
|
1141
1062
|
|
1142
|
-
*
|
1063
|
+
*parsing_.value += ((static_cast<uint32_t>(*cur)) & 0x7f) << 14;
|
1143
1064
|
|
1144
1065
|
if ((*cur) & 0x80) {
|
1145
|
-
return parse_value3(
|
1066
|
+
return parse_value3(cur + 1, end);
|
1146
1067
|
} else {
|
1147
|
-
return parse_next(
|
1068
|
+
return parse_next(cur + 1, end);
|
1148
1069
|
}
|
1149
1070
|
}
|
1150
1071
|
|
1151
|
-
/* parse the 4th byte of a varint into
|
1072
|
+
/* parse the 4th byte of a varint into parsing_.value
|
1152
1073
|
no overflow is possible */
|
1153
|
-
|
1154
|
-
|
1074
|
+
grpc_error_handle HPackParser::parse_value3(const uint8_t* cur,
|
1075
|
+
const uint8_t* end) {
|
1155
1076
|
if (cur == end) {
|
1156
|
-
|
1077
|
+
state_ = &HPackParser::parse_value3;
|
1157
1078
|
return GRPC_ERROR_NONE;
|
1158
1079
|
}
|
1159
1080
|
|
1160
|
-
*
|
1081
|
+
*parsing_.value += ((static_cast<uint32_t>(*cur)) & 0x7f) << 21;
|
1161
1082
|
|
1162
1083
|
if ((*cur) & 0x80) {
|
1163
|
-
return parse_value4(
|
1084
|
+
return parse_value4(cur + 1, end);
|
1164
1085
|
} else {
|
1165
|
-
return parse_next(
|
1086
|
+
return parse_next(cur + 1, end);
|
1166
1087
|
}
|
1167
1088
|
}
|
1168
1089
|
|
1169
|
-
/* parse the 5th byte of a varint into
|
1090
|
+
/* parse the 5th byte of a varint into parsing_.value
|
1170
1091
|
depending on the byte, we may overflow, and care must be taken */
|
1171
|
-
|
1172
|
-
|
1092
|
+
grpc_error_handle HPackParser::parse_value4(const uint8_t* cur,
|
1093
|
+
const uint8_t* end) {
|
1173
1094
|
uint8_t c;
|
1174
1095
|
uint32_t cur_value;
|
1175
1096
|
uint32_t add_value;
|
1176
1097
|
|
1177
1098
|
if (cur == end) {
|
1178
|
-
|
1099
|
+
state_ = &HPackParser::parse_value4;
|
1179
1100
|
return GRPC_ERROR_NONE;
|
1180
1101
|
}
|
1181
1102
|
|
@@ -1184,369 +1105,366 @@ static grpc_error* parse_value4(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
|
1184
1105
|
goto error;
|
1185
1106
|
}
|
1186
1107
|
|
1187
|
-
cur_value = *
|
1108
|
+
cur_value = *parsing_.value;
|
1188
1109
|
add_value = (static_cast<uint32_t>(c)) << 28;
|
1189
1110
|
if (add_value > 0xffffffffu - cur_value) {
|
1190
1111
|
goto error;
|
1191
1112
|
}
|
1192
1113
|
|
1193
|
-
*
|
1114
|
+
*parsing_.value = cur_value + add_value;
|
1194
1115
|
|
1195
1116
|
if ((*cur) & 0x80) {
|
1196
|
-
return parse_value5up(
|
1117
|
+
return parse_value5up(cur + 1, end);
|
1197
1118
|
} else {
|
1198
|
-
return parse_next(
|
1119
|
+
return parse_next(cur + 1, end);
|
1199
1120
|
}
|
1200
1121
|
|
1201
1122
|
error:
|
1202
|
-
|
1123
|
+
grpc_error_handle err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1203
1124
|
absl::StrFormat(
|
1204
1125
|
"integer overflow in hpack integer decoding: have 0x%08x, "
|
1205
1126
|
"got byte 0x%02x on byte 5",
|
1206
|
-
*
|
1127
|
+
*parsing_.value, *cur)
|
1207
1128
|
.c_str());
|
1208
|
-
return parse_error(
|
1129
|
+
return parse_error(cur, end, err);
|
1209
1130
|
}
|
1210
1131
|
|
1211
1132
|
/* parse any trailing bytes in a varint: it's possible to append an arbitrary
|
1212
1133
|
number of 0x80's and not affect the value - a zero will terminate - and
|
1213
1134
|
anything else will overflow */
|
1214
|
-
|
1215
|
-
|
1135
|
+
grpc_error_handle HPackParser::parse_value5up(const uint8_t* cur,
|
1136
|
+
const uint8_t* end) {
|
1216
1137
|
while (cur != end && *cur == 0x80) {
|
1217
1138
|
++cur;
|
1218
1139
|
}
|
1219
1140
|
|
1220
1141
|
if (cur == end) {
|
1221
|
-
|
1142
|
+
state_ = &HPackParser::parse_value5up;
|
1222
1143
|
return GRPC_ERROR_NONE;
|
1223
1144
|
}
|
1224
1145
|
|
1225
1146
|
if (*cur == 0) {
|
1226
|
-
return parse_next(
|
1147
|
+
return parse_next(cur + 1, end);
|
1227
1148
|
}
|
1228
1149
|
|
1229
|
-
|
1150
|
+
grpc_error_handle err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1230
1151
|
absl::StrFormat(
|
1231
1152
|
"integer overflow in hpack integer decoding: have 0x%08x, "
|
1232
1153
|
"got byte 0x%02x sometime after byte 5",
|
1233
|
-
*
|
1154
|
+
*parsing_.value, *cur)
|
1234
1155
|
.c_str());
|
1235
|
-
return parse_error(
|
1156
|
+
return parse_error(cur, end, err);
|
1236
1157
|
}
|
1237
1158
|
|
1238
1159
|
/* parse a string prefix */
|
1239
|
-
|
1240
|
-
|
1160
|
+
grpc_error_handle HPackParser::parse_string_prefix(const uint8_t* cur,
|
1161
|
+
const uint8_t* end) {
|
1241
1162
|
if (cur == end) {
|
1242
|
-
|
1163
|
+
state_ = &HPackParser::parse_string_prefix;
|
1243
1164
|
return GRPC_ERROR_NONE;
|
1244
1165
|
}
|
1245
1166
|
|
1246
|
-
|
1247
|
-
|
1248
|
-
if (
|
1249
|
-
|
1250
|
-
return parse_value0(
|
1167
|
+
strlen_ = (*cur) & 0x7f;
|
1168
|
+
huff_ = (*cur) >> 7;
|
1169
|
+
if (strlen_ == 0x7f) {
|
1170
|
+
parsing_.value = &strlen_;
|
1171
|
+
return parse_value0(cur + 1, end);
|
1251
1172
|
} else {
|
1252
|
-
return parse_next(
|
1173
|
+
return parse_next(cur + 1, end);
|
1253
1174
|
}
|
1254
1175
|
}
|
1255
1176
|
|
1256
1177
|
/* append some bytes to a string */
|
1257
|
-
|
1258
|
-
const uint8_t* data, size_t length) {
|
1178
|
+
void HPackParser::String::AppendBytes(const uint8_t* data, size_t length) {
|
1259
1179
|
if (length == 0) return;
|
1260
|
-
if (length +
|
1261
|
-
GPR_ASSERT(
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
gpr_realloc(str->data.copied.str, str->data.copied.capacity));
|
1180
|
+
if (length + data_.copied.length > data_.copied.capacity) {
|
1181
|
+
GPR_ASSERT(data_.copied.length + length <= UINT32_MAX);
|
1182
|
+
data_.copied.capacity = static_cast<uint32_t>(data_.copied.length + length);
|
1183
|
+
data_.copied.str = static_cast<char*>(
|
1184
|
+
gpr_realloc(data_.copied.str, data_.copied.capacity));
|
1266
1185
|
}
|
1267
|
-
memcpy(
|
1268
|
-
GPR_ASSERT(length <= UINT32_MAX -
|
1269
|
-
|
1186
|
+
memcpy(data_.copied.str + data_.copied.length, data, length);
|
1187
|
+
GPR_ASSERT(length <= UINT32_MAX - data_.copied.length);
|
1188
|
+
data_.copied.length += static_cast<uint32_t>(length);
|
1270
1189
|
}
|
1271
1190
|
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1191
|
+
grpc_error_handle HPackParser::AppendString(const uint8_t* cur,
|
1192
|
+
const uint8_t* end) {
|
1193
|
+
String* str = parsing_.str;
|
1275
1194
|
uint32_t bits;
|
1276
1195
|
uint8_t decoded[3];
|
1277
|
-
switch (
|
1278
|
-
case
|
1279
|
-
|
1196
|
+
switch (binary_) {
|
1197
|
+
case BinaryState::kNotBinary:
|
1198
|
+
str->AppendBytes(cur, static_cast<size_t>(end - cur));
|
1280
1199
|
return GRPC_ERROR_NONE;
|
1281
|
-
case
|
1200
|
+
case BinaryState::kBinaryBegin:
|
1282
1201
|
if (cur == end) {
|
1283
|
-
|
1202
|
+
binary_ = BinaryState::kBinaryBegin;
|
1284
1203
|
return GRPC_ERROR_NONE;
|
1285
1204
|
}
|
1286
1205
|
if (*cur == 0) {
|
1287
1206
|
/* 'true-binary' case */
|
1288
1207
|
++cur;
|
1289
|
-
|
1208
|
+
binary_ = BinaryState::kNotBinary;
|
1290
1209
|
GRPC_STATS_INC_HPACK_RECV_BINARY();
|
1291
|
-
|
1210
|
+
str->AppendBytes(cur, static_cast<size_t>(end - cur));
|
1292
1211
|
return GRPC_ERROR_NONE;
|
1293
1212
|
}
|
1294
1213
|
GRPC_STATS_INC_HPACK_RECV_BINARY_BASE64();
|
1295
|
-
/* fallthrough */
|
1296
1214
|
b64_byte0:
|
1297
|
-
|
1215
|
+
ABSL_FALLTHROUGH_INTENDED;
|
1216
|
+
case BinaryState::kBase64Byte0:
|
1298
1217
|
if (cur == end) {
|
1299
|
-
|
1218
|
+
binary_ = BinaryState::kBase64Byte0;
|
1300
1219
|
return GRPC_ERROR_NONE;
|
1301
1220
|
}
|
1302
|
-
bits =
|
1221
|
+
bits = kBase64InverseTable.table[*cur];
|
1303
1222
|
++cur;
|
1304
1223
|
if (bits == 255) {
|
1305
1224
|
return parse_error(
|
1306
|
-
|
1225
|
+
cur, end,
|
1307
1226
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
|
1308
1227
|
} else if (bits == 64) {
|
1309
1228
|
goto b64_byte0;
|
1310
1229
|
}
|
1311
|
-
|
1312
|
-
/* fallthrough */
|
1230
|
+
base64_buffer_ = bits << 18;
|
1313
1231
|
b64_byte1:
|
1314
|
-
|
1232
|
+
ABSL_FALLTHROUGH_INTENDED;
|
1233
|
+
case BinaryState::kBase64Byte1:
|
1315
1234
|
if (cur == end) {
|
1316
|
-
|
1235
|
+
binary_ = BinaryState::kBase64Byte1;
|
1317
1236
|
return GRPC_ERROR_NONE;
|
1318
1237
|
}
|
1319
|
-
bits =
|
1238
|
+
bits = kBase64InverseTable.table[*cur];
|
1320
1239
|
++cur;
|
1321
1240
|
if (bits == 255) {
|
1322
1241
|
return parse_error(
|
1323
|
-
|
1242
|
+
cur, end,
|
1324
1243
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
|
1325
1244
|
} else if (bits == 64) {
|
1326
1245
|
goto b64_byte1;
|
1327
1246
|
}
|
1328
|
-
|
1329
|
-
/* fallthrough */
|
1247
|
+
base64_buffer_ |= bits << 12;
|
1330
1248
|
b64_byte2:
|
1331
|
-
|
1249
|
+
ABSL_FALLTHROUGH_INTENDED;
|
1250
|
+
case BinaryState::kBase64Byte2:
|
1332
1251
|
if (cur == end) {
|
1333
|
-
|
1252
|
+
binary_ = BinaryState::kBase64Byte2;
|
1334
1253
|
return GRPC_ERROR_NONE;
|
1335
1254
|
}
|
1336
|
-
bits =
|
1255
|
+
bits = kBase64InverseTable.table[*cur];
|
1337
1256
|
++cur;
|
1338
1257
|
if (bits == 255) {
|
1339
1258
|
return parse_error(
|
1340
|
-
|
1259
|
+
cur, end,
|
1341
1260
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
|
1342
1261
|
} else if (bits == 64) {
|
1343
1262
|
goto b64_byte2;
|
1344
1263
|
}
|
1345
|
-
|
1346
|
-
/* fallthrough */
|
1264
|
+
base64_buffer_ |= bits << 6;
|
1347
1265
|
b64_byte3:
|
1348
|
-
|
1266
|
+
ABSL_FALLTHROUGH_INTENDED;
|
1267
|
+
case BinaryState::kBase64Byte3:
|
1349
1268
|
if (cur == end) {
|
1350
|
-
|
1269
|
+
binary_ = BinaryState::kBase64Byte3;
|
1351
1270
|
return GRPC_ERROR_NONE;
|
1352
1271
|
}
|
1353
|
-
bits =
|
1272
|
+
bits = kBase64InverseTable.table[*cur];
|
1354
1273
|
++cur;
|
1355
1274
|
if (bits == 255) {
|
1356
1275
|
return parse_error(
|
1357
|
-
|
1276
|
+
cur, end,
|
1358
1277
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
|
1359
1278
|
} else if (bits == 64) {
|
1360
1279
|
goto b64_byte3;
|
1361
1280
|
}
|
1362
|
-
|
1363
|
-
bits =
|
1281
|
+
base64_buffer_ |= bits;
|
1282
|
+
bits = base64_buffer_;
|
1364
1283
|
decoded[0] = static_cast<uint8_t>(bits >> 16);
|
1365
1284
|
decoded[1] = static_cast<uint8_t>(bits >> 8);
|
1366
1285
|
decoded[2] = static_cast<uint8_t>(bits);
|
1367
|
-
|
1286
|
+
str->AppendBytes(decoded, 3);
|
1368
1287
|
goto b64_byte0;
|
1369
1288
|
}
|
1370
1289
|
GPR_UNREACHABLE_CODE(return parse_error(
|
1371
|
-
|
1290
|
+
cur, end,
|
1372
1291
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Should never reach here")));
|
1373
1292
|
}
|
1374
1293
|
|
1375
|
-
|
1376
|
-
|
1294
|
+
grpc_error_handle HPackParser::finish_str(const uint8_t* cur,
|
1295
|
+
const uint8_t* end) {
|
1377
1296
|
uint8_t decoded[2];
|
1378
1297
|
uint32_t bits;
|
1379
|
-
|
1380
|
-
switch (
|
1381
|
-
case
|
1298
|
+
String* str = parsing_.str;
|
1299
|
+
switch (binary_) {
|
1300
|
+
case BinaryState::kNotBinary:
|
1382
1301
|
break;
|
1383
|
-
case
|
1302
|
+
case BinaryState::kBinaryBegin:
|
1384
1303
|
break;
|
1385
|
-
case
|
1304
|
+
case BinaryState::kBase64Byte0:
|
1386
1305
|
break;
|
1387
|
-
case
|
1388
|
-
return parse_error(
|
1306
|
+
case BinaryState::kBase64Byte1:
|
1307
|
+
return parse_error(cur, end,
|
1389
1308
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1390
1309
|
"illegal base64 encoding")); /* illegal encoding */
|
1391
|
-
case
|
1392
|
-
bits =
|
1310
|
+
case BinaryState::kBase64Byte2:
|
1311
|
+
bits = base64_buffer_;
|
1393
1312
|
if (bits & 0xffff) {
|
1394
|
-
|
1313
|
+
grpc_error_handle err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1395
1314
|
absl::StrFormat("trailing bits in base64 encoding: 0x%04x",
|
1396
1315
|
bits & 0xffff)
|
1397
1316
|
.c_str());
|
1398
|
-
return parse_error(
|
1317
|
+
return parse_error(cur, end, err);
|
1399
1318
|
}
|
1400
1319
|
decoded[0] = static_cast<uint8_t>(bits >> 16);
|
1401
|
-
|
1320
|
+
str->AppendBytes(decoded, 1);
|
1402
1321
|
break;
|
1403
|
-
case
|
1404
|
-
bits =
|
1322
|
+
case BinaryState::kBase64Byte3:
|
1323
|
+
bits = base64_buffer_;
|
1405
1324
|
if (bits & 0xff) {
|
1406
|
-
|
1325
|
+
grpc_error_handle err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
1407
1326
|
absl::StrFormat("trailing bits in base64 encoding: 0x%02x",
|
1408
1327
|
bits & 0xff)
|
1409
1328
|
.c_str());
|
1410
|
-
return parse_error(
|
1329
|
+
return parse_error(cur, end, err);
|
1411
1330
|
}
|
1412
1331
|
decoded[0] = static_cast<uint8_t>(bits >> 16);
|
1413
1332
|
decoded[1] = static_cast<uint8_t>(bits >> 8);
|
1414
|
-
|
1333
|
+
str->AppendBytes(decoded, 2);
|
1415
1334
|
break;
|
1416
1335
|
}
|
1417
1336
|
return GRPC_ERROR_NONE;
|
1418
1337
|
}
|
1419
1338
|
|
1420
1339
|
/* decode a nibble from a huffman encoded stream */
|
1421
|
-
|
1422
|
-
int16_t emit = emit_sub_tbl[16 * emit_tbl[
|
1423
|
-
int16_t next = next_sub_tbl[16 * next_tbl[
|
1340
|
+
grpc_error_handle HPackParser::AppendHuffNibble(uint8_t nibble) {
|
1341
|
+
int16_t emit = emit_sub_tbl[16 * emit_tbl[huff_state_] + nibble];
|
1342
|
+
int16_t next = next_sub_tbl[16 * next_tbl[huff_state_] + nibble];
|
1424
1343
|
if (emit != -1) {
|
1425
1344
|
if (emit >= 0 && emit < 256) {
|
1426
1345
|
uint8_t c = static_cast<uint8_t>(emit);
|
1427
|
-
|
1346
|
+
grpc_error_handle err = AppendString(&c, (&c) + 1);
|
1428
1347
|
if (err != GRPC_ERROR_NONE) return err;
|
1429
1348
|
} else {
|
1430
1349
|
assert(emit == 256);
|
1431
1350
|
}
|
1432
1351
|
}
|
1433
|
-
|
1352
|
+
huff_state_ = next;
|
1434
1353
|
return GRPC_ERROR_NONE;
|
1435
1354
|
}
|
1436
1355
|
|
1437
1356
|
/* decode full bytes from a huffman encoded stream */
|
1438
|
-
|
1439
|
-
|
1357
|
+
grpc_error_handle HPackParser::AppendHuffBytes(const uint8_t* cur,
|
1358
|
+
const uint8_t* end) {
|
1440
1359
|
for (; cur != end; ++cur) {
|
1441
|
-
|
1442
|
-
if (err != GRPC_ERROR_NONE) return parse_error(
|
1443
|
-
err =
|
1444
|
-
if (err != GRPC_ERROR_NONE) return parse_error(
|
1360
|
+
grpc_error_handle err = AppendHuffNibble(*cur >> 4);
|
1361
|
+
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
1362
|
+
err = AppendHuffNibble(*cur & 0xf);
|
1363
|
+
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
1445
1364
|
}
|
1446
1365
|
return GRPC_ERROR_NONE;
|
1447
1366
|
}
|
1448
1367
|
|
1449
1368
|
/* decode some string bytes based on the current decoding mode
|
1450
1369
|
(huffman or not) */
|
1451
|
-
|
1452
|
-
|
1453
|
-
if (
|
1454
|
-
return
|
1370
|
+
grpc_error_handle HPackParser::AppendStrBytes(const uint8_t* cur,
|
1371
|
+
const uint8_t* end) {
|
1372
|
+
if (huff_) {
|
1373
|
+
return AppendHuffBytes(cur, end);
|
1455
1374
|
} else {
|
1456
|
-
return
|
1375
|
+
return AppendString(cur, end);
|
1457
1376
|
}
|
1458
1377
|
}
|
1459
1378
|
|
1460
1379
|
/* parse a string - tries to do large chunks at a time */
|
1461
|
-
|
1462
|
-
|
1463
|
-
size_t remaining =
|
1380
|
+
grpc_error_handle HPackParser::parse_string(const uint8_t* cur,
|
1381
|
+
const uint8_t* end) {
|
1382
|
+
size_t remaining = strlen_ - strgot_;
|
1464
1383
|
size_t given = static_cast<size_t>(end - cur);
|
1465
1384
|
if (remaining <= given) {
|
1466
|
-
|
1467
|
-
if (err != GRPC_ERROR_NONE) return parse_error(
|
1468
|
-
err = finish_str(
|
1469
|
-
if (err != GRPC_ERROR_NONE) return parse_error(
|
1470
|
-
return parse_next(
|
1385
|
+
grpc_error_handle err = AppendStrBytes(cur, cur + remaining);
|
1386
|
+
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
1387
|
+
err = finish_str(cur + remaining, end);
|
1388
|
+
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
1389
|
+
return parse_next(cur + remaining, end);
|
1471
1390
|
} else {
|
1472
|
-
|
1473
|
-
if (err != GRPC_ERROR_NONE) return parse_error(
|
1474
|
-
GPR_ASSERT(given <= UINT32_MAX -
|
1475
|
-
|
1476
|
-
|
1391
|
+
grpc_error_handle err = AppendStrBytes(cur, cur + given);
|
1392
|
+
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
1393
|
+
GPR_ASSERT(given <= UINT32_MAX - strgot_);
|
1394
|
+
strgot_ += static_cast<uint32_t>(given);
|
1395
|
+
state_ = &HPackParser::parse_string;
|
1477
1396
|
return GRPC_ERROR_NONE;
|
1478
1397
|
}
|
1479
1398
|
}
|
1480
1399
|
|
1481
1400
|
/* begin parsing a string - performs setup, calls parse_string */
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
if (!
|
1487
|
-
static_cast<uint32_t>(end - cur) >=
|
1488
|
-
|
1401
|
+
grpc_error_handle HPackParser::begin_parse_string(const uint8_t* cur,
|
1402
|
+
const uint8_t* end,
|
1403
|
+
BinaryState binary,
|
1404
|
+
HPackParser::String* str) {
|
1405
|
+
if (!huff_ && binary == BinaryState::kNotBinary &&
|
1406
|
+
static_cast<uint32_t>(end - cur) >= strlen_ &&
|
1407
|
+
current_slice_refcount_ != nullptr) {
|
1489
1408
|
GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED();
|
1490
|
-
str->
|
1491
|
-
str->
|
1492
|
-
str->
|
1493
|
-
str->
|
1494
|
-
grpc_slice_ref_internal(str->
|
1495
|
-
return parse_next(
|
1409
|
+
str->copied_ = false;
|
1410
|
+
str->data_.referenced.refcount = current_slice_refcount_;
|
1411
|
+
str->data_.referenced.data.refcounted.bytes = const_cast<uint8_t*>(cur);
|
1412
|
+
str->data_.referenced.data.refcounted.length = strlen_;
|
1413
|
+
grpc_slice_ref_internal(str->data_.referenced);
|
1414
|
+
return parse_next(cur + strlen_, end);
|
1496
1415
|
}
|
1497
|
-
|
1498
|
-
str->
|
1499
|
-
str->
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
switch (
|
1504
|
-
case
|
1505
|
-
if (
|
1416
|
+
strgot_ = 0;
|
1417
|
+
str->copied_ = true;
|
1418
|
+
str->data_.copied.length = 0;
|
1419
|
+
parsing_.str = str;
|
1420
|
+
huff_state_ = 0;
|
1421
|
+
binary_ = binary;
|
1422
|
+
switch (binary_) {
|
1423
|
+
case BinaryState::kNotBinary:
|
1424
|
+
if (huff_) {
|
1506
1425
|
GRPC_STATS_INC_HPACK_RECV_HUFFMAN();
|
1507
1426
|
} else {
|
1508
1427
|
GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED();
|
1509
1428
|
}
|
1510
1429
|
break;
|
1511
|
-
case
|
1430
|
+
case BinaryState::kBinaryBegin:
|
1512
1431
|
/* stats incremented later: don't know true binary or not */
|
1513
1432
|
break;
|
1514
1433
|
default:
|
1515
1434
|
abort();
|
1516
1435
|
}
|
1517
|
-
return parse_string(
|
1436
|
+
return parse_string(cur, end);
|
1518
1437
|
}
|
1519
1438
|
|
1520
1439
|
/* parse the key string */
|
1521
|
-
|
1522
|
-
|
1523
|
-
return begin_parse_string(
|
1440
|
+
grpc_error_handle HPackParser::parse_key_string(const uint8_t* cur,
|
1441
|
+
const uint8_t* end) {
|
1442
|
+
return begin_parse_string(cur, end, BinaryState::kNotBinary, &key_);
|
1524
1443
|
}
|
1525
1444
|
|
1526
1445
|
/* check if a key represents a binary header or not */
|
1527
1446
|
|
1528
|
-
|
1447
|
+
bool HPackParser::IsBinaryLiteralHeader() {
|
1529
1448
|
/* We know that either argument here is a reference counter slice.
|
1530
1449
|
* 1. If it is a grpc_core::StaticSlice, the refcount is set to kNoopRefcount.
|
1531
|
-
* 2. If it's
|
1450
|
+
* 2. If it's key_.data.referenced, then key_.copied was set to false,
|
1532
1451
|
* which occurs in begin_parse_string() - where the refcount is set to
|
1533
|
-
*
|
1452
|
+
* current_slice_refcount_, which is not null. */
|
1534
1453
|
return grpc_is_refcounted_slice_binary_header(
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1454
|
+
key_.copied_ ? grpc_core::ExternallyManagedSlice(key_.data_.copied.str,
|
1455
|
+
key_.data_.copied.length)
|
1456
|
+
: key_.data_.referenced);
|
1538
1457
|
}
|
1539
1458
|
|
1540
1459
|
/* Cache the metadata for the given index during initial parsing. This avoids a
|
1541
1460
|
pointless recomputation of the metadata when finishing a header. We read the
|
1542
1461
|
cached value in get_precomputed_md_for_idx(). */
|
1543
|
-
|
1544
|
-
|
1545
|
-
GPR_DEBUG_ASSERT(
|
1546
|
-
|
1547
|
-
p->md_for_index = md;
|
1462
|
+
void HPackParser::SetPrecomputedMDIndex(grpc_mdelem md) {
|
1463
|
+
GPR_DEBUG_ASSERT(md_for_index_.payload == 0);
|
1464
|
+
GPR_DEBUG_ASSERT(precomputed_md_index_ == -1);
|
1465
|
+
md_for_index_ = md;
|
1548
1466
|
#ifndef NDEBUG
|
1549
|
-
|
1467
|
+
precomputed_md_index_ = index_;
|
1550
1468
|
#endif
|
1551
1469
|
}
|
1552
1470
|
|
@@ -1554,11 +1472,10 @@ static void set_precomputed_md_idx(grpc_chttp2_hpack_parser* p,
|
|
1554
1472
|
is a binary indexed header during string parsing. We'll need to revisit this
|
1555
1473
|
metadata when we're done parsing, so we cache the metadata for this index
|
1556
1474
|
here using set_precomputed_md_idx(). */
|
1557
|
-
|
1558
|
-
|
1559
|
-
grpc_mdelem elem = grpc_chttp2_hptbl_lookup(&p->table, p->index);
|
1475
|
+
grpc_error_handle HPackParser::IsBinaryIndexedHeader(bool* is) {
|
1476
|
+
grpc_mdelem elem = grpc_chttp2_hptbl_lookup(&table_, index_);
|
1560
1477
|
if (GPR_UNLIKELY(GRPC_MDISNULL(elem))) {
|
1561
|
-
return
|
1478
|
+
return InvalidHPackIndexError();
|
1562
1479
|
}
|
1563
1480
|
/* We know that GRPC_MDKEY(elem) points to a reference counted slice since:
|
1564
1481
|
* 1. elem was a result of grpc_chttp2_hptbl_lookup
|
@@ -1569,107 +1486,111 @@ static grpc_error* is_binary_indexed_header(grpc_chttp2_hpack_parser* p,
|
|
1569
1486
|
* interned.
|
1570
1487
|
* 4. Both static and interned element slices have non-null refcounts. */
|
1571
1488
|
*is = grpc_is_refcounted_slice_binary_header(GRPC_MDKEY(elem));
|
1572
|
-
|
1489
|
+
SetPrecomputedMDIndex(elem);
|
1573
1490
|
return GRPC_ERROR_NONE;
|
1574
1491
|
}
|
1575
1492
|
|
1576
1493
|
/* parse the value string */
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
return begin_parse_string(
|
1581
|
-
|
1494
|
+
grpc_error_handle HPackParser::parse_value_string(const uint8_t* cur,
|
1495
|
+
const uint8_t* end,
|
1496
|
+
bool is_binary) {
|
1497
|
+
return begin_parse_string(
|
1498
|
+
cur, end, is_binary ? BinaryState::kBinaryBegin : BinaryState::kNotBinary,
|
1499
|
+
&value_);
|
1582
1500
|
}
|
1583
1501
|
|
1584
|
-
|
1585
|
-
|
1502
|
+
grpc_error_handle HPackParser::parse_value_string_with_indexed_key(
|
1503
|
+
const uint8_t* cur, const uint8_t* end) {
|
1586
1504
|
bool is_binary = false;
|
1587
|
-
|
1588
|
-
if (err != GRPC_ERROR_NONE) return parse_error(
|
1589
|
-
return parse_value_string(
|
1590
|
-
}
|
1591
|
-
|
1592
|
-
static grpc_error* parse_value_string_with_literal_key(
|
1593
|
-
grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) {
|
1594
|
-
return parse_value_string(p, cur, end, is_binary_literal_header(p));
|
1505
|
+
grpc_error_handle err = IsBinaryIndexedHeader(&is_binary);
|
1506
|
+
if (err != GRPC_ERROR_NONE) return parse_error(cur, end, err);
|
1507
|
+
return parse_value_string(cur, end, is_binary);
|
1595
1508
|
}
|
1596
1509
|
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
GRPC_MDELEM_UNREF(md);
|
1601
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("on_header callback not set");
|
1510
|
+
grpc_error_handle HPackParser::parse_value_string_with_literal_key(
|
1511
|
+
const uint8_t* cur, const uint8_t* end) {
|
1512
|
+
return parse_value_string(cur, end, IsBinaryLiteralHeader());
|
1602
1513
|
}
|
1603
1514
|
|
1604
1515
|
/* PUBLIC INTERFACE */
|
1605
1516
|
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
p->value.data.copied.capacity = 0;
|
1617
|
-
p->value.data.copied.length = 0;
|
1517
|
+
HPackParser::HPackParser() {
|
1518
|
+
state_ = &HPackParser::parse_begin;
|
1519
|
+
key_.data_.referenced = grpc_empty_slice();
|
1520
|
+
key_.data_.copied.str = nullptr;
|
1521
|
+
key_.data_.copied.capacity = 0;
|
1522
|
+
key_.data_.copied.length = 0;
|
1523
|
+
value_.data_.referenced = grpc_empty_slice();
|
1524
|
+
value_.data_.copied.str = nullptr;
|
1525
|
+
value_.data_.copied.capacity = 0;
|
1526
|
+
value_.data_.copied.length = 0;
|
1618
1527
|
/* Cached metadata for the current index the parser is handling. This is set
|
1619
1528
|
to 0 initially, invalidated when the index changes, and invalidated when it
|
1620
1529
|
is read (by get_precomputed_md_for_idx()). It is set during string parsing,
|
1621
1530
|
by set_precomputed_md_idx() - which is called by parse_value_string().
|
1622
1531
|
The goal here is to avoid recomputing the metadata for the index when
|
1623
1532
|
finishing with a header as well as the initial parse. */
|
1624
|
-
|
1533
|
+
md_for_index_.payload = 0;
|
1625
1534
|
#ifndef NDEBUG
|
1626
1535
|
/* In debug mode, this ensures that the cached metadata we're reading is in
|
1627
1536
|
* fact correct for the index we are examining. */
|
1628
|
-
|
1537
|
+
precomputed_md_index_ = -1;
|
1629
1538
|
#endif
|
1630
|
-
|
1631
|
-
|
1539
|
+
dynamic_table_updates_allowed_ = 2;
|
1540
|
+
last_error_ = GRPC_ERROR_NONE;
|
1632
1541
|
}
|
1633
1542
|
|
1634
|
-
void
|
1635
|
-
|
1636
|
-
|
1543
|
+
void HPackParser::BeginFrame(Sink sink, Boundary boundary, Priority priority) {
|
1544
|
+
sink_ = std::move(sink);
|
1545
|
+
boundary_ = boundary;
|
1546
|
+
switch (priority) {
|
1547
|
+
case Priority::Included:
|
1548
|
+
after_prioritization_ = state_;
|
1549
|
+
state_ = &HPackParser::parse_stream_dep0;
|
1550
|
+
break;
|
1551
|
+
case Priority::None:
|
1552
|
+
break;
|
1553
|
+
}
|
1637
1554
|
}
|
1638
1555
|
|
1639
|
-
|
1640
|
-
grpc_chttp2_hptbl_destroy(&
|
1641
|
-
GRPC_ERROR_UNREF(
|
1642
|
-
grpc_slice_unref_internal(
|
1643
|
-
grpc_slice_unref_internal(
|
1644
|
-
gpr_free(
|
1645
|
-
gpr_free(
|
1556
|
+
HPackParser::~HPackParser() {
|
1557
|
+
grpc_chttp2_hptbl_destroy(&table_);
|
1558
|
+
GRPC_ERROR_UNREF(last_error_);
|
1559
|
+
grpc_slice_unref_internal(key_.data_.referenced);
|
1560
|
+
grpc_slice_unref_internal(value_.data_.referenced);
|
1561
|
+
gpr_free(key_.data_.copied.str);
|
1562
|
+
gpr_free(value_.data_.copied.str);
|
1646
1563
|
}
|
1647
1564
|
|
1648
|
-
|
1649
|
-
const grpc_slice& slice) {
|
1565
|
+
grpc_error_handle HPackParser::Parse(const grpc_slice& slice) {
|
1650
1566
|
/* max number of bytes to parse at a time... limits call stack depth on
|
1651
1567
|
* compilers without TCO */
|
1652
1568
|
#define MAX_PARSE_LENGTH 1024
|
1653
|
-
|
1569
|
+
current_slice_refcount_ = slice.refcount;
|
1654
1570
|
const uint8_t* start = GRPC_SLICE_START_PTR(slice);
|
1655
1571
|
const uint8_t* end = GRPC_SLICE_END_PTR(slice);
|
1656
|
-
|
1572
|
+
grpc_error_handle error = GRPC_ERROR_NONE;
|
1657
1573
|
while (start != end && error == GRPC_ERROR_NONE) {
|
1658
1574
|
const uint8_t* target = start + GPR_MIN(MAX_PARSE_LENGTH, end - start);
|
1659
|
-
error =
|
1575
|
+
error = (this->*state_)(start, target);
|
1660
1576
|
start = target;
|
1661
1577
|
}
|
1662
|
-
|
1578
|
+
current_slice_refcount_ = nullptr;
|
1663
1579
|
return error;
|
1664
1580
|
}
|
1665
1581
|
|
1582
|
+
} // namespace grpc_core
|
1583
|
+
|
1584
|
+
// TODO(ctiller): this serves as an eviction notice for the remainder of this
|
1585
|
+
// file... it belongs elsewhere!
|
1586
|
+
|
1666
1587
|
typedef void (*maybe_complete_func_type)(grpc_chttp2_transport* t,
|
1667
1588
|
grpc_chttp2_stream* s);
|
1668
1589
|
static const maybe_complete_func_type maybe_complete_funcs[] = {
|
1669
1590
|
grpc_chttp2_maybe_complete_recv_initial_metadata,
|
1670
1591
|
grpc_chttp2_maybe_complete_recv_trailing_metadata};
|
1671
1592
|
|
1672
|
-
static void force_client_rst_stream(void* sp,
|
1593
|
+
static void force_client_rst_stream(void* sp, grpc_error_handle /*error*/) {
|
1673
1594
|
grpc_chttp2_stream* s = static_cast<grpc_chttp2_stream*>(sp);
|
1674
1595
|
grpc_chttp2_transport* t = s->t;
|
1675
1596
|
if (!s->write_closed) {
|
@@ -1699,30 +1620,29 @@ static void parse_stream_compression_md(grpc_chttp2_transport* /*t*/,
|
|
1699
1620
|
}
|
1700
1621
|
}
|
1701
1622
|
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1623
|
+
grpc_error_handle grpc_chttp2_header_parser_parse(void* hpack_parser,
|
1624
|
+
grpc_chttp2_transport* t,
|
1625
|
+
grpc_chttp2_stream* s,
|
1626
|
+
const grpc_slice& slice,
|
1627
|
+
int is_last) {
|
1707
1628
|
GPR_TIMER_SCOPE("grpc_chttp2_header_parser_parse", 0);
|
1708
|
-
|
1709
|
-
static_cast<grpc_chttp2_hpack_parser*>(hpack_parser);
|
1629
|
+
auto* parser = static_cast<grpc_core::HPackParser*>(hpack_parser);
|
1710
1630
|
if (s != nullptr) {
|
1711
1631
|
s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice);
|
1712
1632
|
}
|
1713
|
-
|
1633
|
+
grpc_error_handle error = parser->Parse(slice);
|
1714
1634
|
if (error != GRPC_ERROR_NONE) {
|
1715
1635
|
return error;
|
1716
1636
|
}
|
1717
1637
|
if (is_last) {
|
1718
|
-
if (parser->is_boundary && parser->
|
1638
|
+
if (parser->is_boundary() && !parser->is_in_begin_state()) {
|
1719
1639
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1720
1640
|
"end of header frame not aligned with a hpack record boundary");
|
1721
1641
|
}
|
1722
1642
|
/* need to check for null stream: this can occur if we receive an invalid
|
1723
1643
|
stream id on a header */
|
1724
1644
|
if (s != nullptr) {
|
1725
|
-
if (parser->is_boundary) {
|
1645
|
+
if (parser->is_boundary()) {
|
1726
1646
|
if (s->header_frames_received == GPR_ARRAY_SIZE(s->metadata_buffer)) {
|
1727
1647
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1728
1648
|
"Too many trailer frames");
|
@@ -1737,7 +1657,7 @@ grpc_error* grpc_chttp2_header_parser_parse(void* hpack_parser,
|
|
1737
1657
|
maybe_complete_funcs[s->header_frames_received](t, s);
|
1738
1658
|
s->header_frames_received++;
|
1739
1659
|
}
|
1740
|
-
if (parser->is_eof) {
|
1660
|
+
if (parser->is_eof()) {
|
1741
1661
|
if (t->is_client && !s->write_closed) {
|
1742
1662
|
/* server eof ==> complete closure; we may need to forcefully close
|
1743
1663
|
the stream. Wait until the combiner lock is ready to be released
|
@@ -1751,11 +1671,7 @@ grpc_error* grpc_chttp2_header_parser_parse(void* hpack_parser,
|
|
1751
1671
|
grpc_chttp2_mark_stream_closed(t, s, true, false, GRPC_ERROR_NONE);
|
1752
1672
|
}
|
1753
1673
|
}
|
1754
|
-
parser->
|
1755
|
-
parser->on_header_user_data = nullptr;
|
1756
|
-
parser->is_boundary = 0xde;
|
1757
|
-
parser->is_eof = 0xde;
|
1758
|
-
parser->dynamic_table_update_allowed = 2;
|
1674
|
+
parser->FinishFrame();
|
1759
1675
|
}
|
1760
1676
|
return GRPC_ERROR_NONE;
|
1761
1677
|
}
|