grpc 1.60.2 → 1.61.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +208 -165
- data/include/grpc/event_engine/event_engine.h +59 -12
- data/include/grpc/event_engine/internal/memory_allocator_impl.h +6 -0
- data/include/grpc/event_engine/internal/slice_cast.h +12 -0
- data/include/grpc/event_engine/memory_allocator.h +3 -1
- data/include/grpc/event_engine/slice.h +5 -0
- data/include/grpc/grpc_security.h +22 -1
- data/include/grpc/impl/call.h +29 -0
- data/include/grpc/impl/channel_arg_names.h +12 -1
- data/include/grpc/impl/slice_type.h +1 -1
- data/include/grpc/module.modulemap +1 -0
- data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +54 -7
- data/src/core/ext/filters/backend_metrics/backend_metric_filter.h +20 -6
- data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +10 -13
- data/src/core/ext/filters/channel_idle/channel_idle_filter.h +18 -10
- data/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +326 -0
- data/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h +143 -0
- data/src/core/ext/filters/client_channel/backend_metric.cc +2 -2
- data/src/core/ext/filters/client_channel/client_channel.cc +32 -6
- data/src/core/ext/filters/client_channel/client_channel_internal.h +2 -0
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +54 -21
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +2 -1
- data/src/core/ext/filters/client_channel/lb_policy/endpoint_list.cc +12 -15
- data/src/core/ext/filters/client_channel/lb_policy/endpoint_list.h +8 -5
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +139 -92
- data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +9 -4
- data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +9 -4
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +10 -11
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +94 -93
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +5 -3
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +12 -15
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +38 -16
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +25 -28
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +10 -10
- data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +37 -35
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +11 -9
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +504 -461
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +232 -122
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +8 -6
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +642 -251
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.h +2 -6
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +7 -8
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +2 -1
- data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +3 -1
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +6 -8
- data/src/core/ext/filters/client_channel/resolver/xds/xds_dependency_manager.cc +1031 -0
- data/src/core/ext/filters/client_channel/resolver/xds/xds_dependency_manager.h +277 -0
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +128 -270
- data/src/core/ext/filters/client_channel/resolver/xds/{xds_resolver.h → xds_resolver_attributes.h} +5 -4
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver_trace.cc +25 -0
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver_trace.h +30 -0
- data/src/core/ext/filters/client_channel/retry_filter.cc +1 -0
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +35 -17
- data/src/core/ext/filters/deadline/deadline_filter.cc +12 -0
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +17 -13
- data/src/core/ext/filters/fault_injection/fault_injection_filter.h +13 -4
- data/src/core/ext/filters/http/client/http_client_filter.cc +23 -32
- data/src/core/ext/filters/http/client/http_client_filter.h +10 -5
- data/src/core/ext/filters/http/client_authority_filter.cc +14 -14
- data/src/core/ext/filters/http/client_authority_filter.h +12 -4
- data/src/core/ext/filters/http/http_filters_plugin.cc +42 -20
- data/src/core/ext/filters/http/message_compress/compression_filter.cc +55 -80
- data/src/core/ext/filters/http/message_compress/compression_filter.h +54 -12
- data/src/core/ext/filters/http/message_compress/legacy_compression_filter.cc +325 -0
- data/src/core/ext/filters/http/message_compress/legacy_compression_filter.h +139 -0
- data/src/core/ext/filters/http/server/http_server_filter.cc +41 -41
- data/src/core/ext/filters/http/server/http_server_filter.h +11 -4
- data/src/core/ext/filters/message_size/message_size_filter.cc +56 -76
- data/src/core/ext/filters/message_size/message_size_filter.h +35 -23
- data/src/core/ext/filters/rbac/rbac_filter.cc +15 -11
- data/src/core/ext/filters/rbac/rbac_filter.h +11 -4
- data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +25 -13
- data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +47 -50
- data/src/core/ext/filters/stateful_session/stateful_session_filter.h +21 -4
- data/src/core/ext/transport/chttp2/alpn/alpn.cc +1 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +2 -2
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +11 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +68 -145
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +3 -3
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +21 -82
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -8
- data/src/core/ext/transport/chttp2/transport/frame.cc +506 -0
- data/src/core/ext/transport/chttp2/transport/frame.h +214 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +33 -79
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +4 -7
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +27 -36
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +0 -2
- data/src/core/ext/transport/chttp2/transport/http2_settings.cc +122 -32
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +142 -37
- data/src/core/ext/transport/chttp2/transport/internal.h +1 -22
- data/src/core/ext/transport/chttp2/transport/parsing.cc +23 -37
- data/src/core/ext/transport/chttp2/transport/writing.cc +26 -58
- data/src/core/ext/transport/inproc/inproc_transport.cc +172 -13
- data/src/core/ext/upb-gen/envoy/extensions/upstreams/http/v3/http_protocol_options.upb.h +712 -0
- data/src/core/ext/upb-gen/envoy/extensions/upstreams/http/v3/http_protocol_options.upb_minitable.c +151 -0
- data/src/core/ext/upb-gen/envoy/extensions/upstreams/http/v3/http_protocol_options.upb_minitable.h +33 -0
- data/src/core/ext/upbdefs-gen/envoy/extensions/upstreams/http/v3/http_protocol_options.upbdefs.c +133 -0
- data/src/core/ext/upbdefs-gen/envoy/extensions/upstreams/http/v3/http_protocol_options.upbdefs.h +50 -0
- data/src/core/ext/xds/certificate_provider_store.cc +2 -1
- data/src/core/ext/xds/certificate_provider_store.h +0 -5
- data/src/core/ext/xds/xds_api.cc +31 -18
- data/src/core/ext/xds/xds_api.h +2 -2
- data/src/core/ext/xds/xds_bootstrap.h +3 -0
- data/src/core/ext/xds/xds_certificate_provider.cc +88 -287
- data/src/core/ext/xds/xds_certificate_provider.h +44 -111
- data/src/core/ext/xds/xds_client.cc +420 -414
- data/src/core/ext/xds/xds_client.h +31 -22
- data/src/core/ext/xds/xds_client_grpc.cc +3 -1
- data/src/core/ext/xds/xds_cluster.cc +104 -11
- data/src/core/ext/xds/xds_cluster.h +9 -1
- data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +9 -5
- data/src/core/ext/xds/xds_common_types.cc +14 -10
- data/src/core/ext/xds/xds_endpoint.cc +9 -4
- data/src/core/ext/xds/xds_endpoint.h +5 -1
- data/src/core/ext/xds/xds_health_status.cc +12 -2
- data/src/core/ext/xds/xds_health_status.h +4 -2
- data/src/core/ext/xds/xds_http_rbac_filter.cc +5 -3
- data/src/core/ext/xds/xds_listener.cc +14 -8
- data/src/core/ext/xds/xds_resource_type_impl.h +6 -4
- data/src/core/ext/xds/xds_route_config.cc +34 -22
- data/src/core/ext/xds/xds_route_config.h +1 -0
- data/src/core/ext/xds/xds_server_config_fetcher.cc +61 -57
- data/src/core/ext/xds/xds_transport.h +3 -0
- data/src/core/ext/xds/xds_transport_grpc.cc +47 -50
- data/src/core/ext/xds/xds_transport_grpc.h +4 -0
- data/src/core/lib/channel/call_tracer.cc +12 -0
- data/src/core/lib/channel/call_tracer.h +17 -3
- data/src/core/lib/channel/channel_args.cc +24 -14
- data/src/core/lib/channel/channel_args.h +74 -13
- data/src/core/lib/channel/channel_stack.cc +27 -0
- data/src/core/lib/channel/channel_stack.h +10 -10
- data/src/core/lib/channel/connected_channel.cc +64 -18
- data/src/core/lib/channel/promise_based_filter.h +1041 -1
- data/src/core/lib/channel/server_call_tracer_filter.cc +43 -35
- data/src/core/lib/compression/compression_internal.cc +0 -3
- data/src/core/lib/event_engine/ares_resolver.cc +35 -14
- data/src/core/lib/event_engine/ares_resolver.h +9 -10
- data/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc +8 -1
- data/src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.cc +132 -0
- data/src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.h +61 -0
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +52 -36
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +4 -9
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc +11 -3
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +9 -2
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +7 -0
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +17 -27
- data/src/core/lib/event_engine/posix_engine/timer_manager.h +0 -3
- data/src/core/lib/event_engine/ref_counted_dns_resolver_interface.h +55 -0
- data/src/core/lib/event_engine/windows/native_windows_dns_resolver.cc +114 -0
- data/src/core/lib/event_engine/windows/native_windows_dns_resolver.h +51 -0
- data/src/core/lib/event_engine/windows/windows_engine.cc +7 -7
- data/src/core/lib/experiments/config.cc +13 -0
- data/src/core/lib/experiments/config.h +3 -0
- data/src/core/lib/experiments/experiments.cc +245 -366
- data/src/core/lib/experiments/experiments.h +50 -156
- data/src/core/lib/gprpp/debug_location.h +13 -0
- data/src/core/lib/gprpp/dual_ref_counted.h +36 -7
- data/src/core/lib/gprpp/orphanable.h +27 -0
- data/src/core/lib/gprpp/ref_counted.h +63 -22
- data/src/core/lib/gprpp/ref_counted_ptr.h +70 -27
- data/src/core/lib/gprpp/ref_counted_string.h +13 -0
- data/src/core/lib/gprpp/status_helper.cc +1 -2
- data/src/core/lib/iomgr/combiner.cc +15 -51
- data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +31 -0
- data/src/core/lib/iomgr/event_engine_shims/endpoint.h +16 -0
- data/src/core/lib/iomgr/tcp_client_posix.cc +4 -3
- data/src/core/lib/load_balancing/lb_policy.h +1 -1
- data/src/core/lib/promise/activity.cc +17 -2
- data/src/core/lib/promise/activity.h +5 -4
- data/src/core/lib/promise/all_ok.h +80 -0
- data/src/core/lib/promise/detail/join_state.h +2077 -0
- data/src/core/lib/promise/detail/promise_factory.h +1 -0
- data/src/core/lib/promise/detail/promise_like.h +8 -1
- data/src/core/lib/promise/detail/seq_state.h +3458 -150
- data/src/core/lib/promise/detail/status.h +42 -5
- data/src/core/lib/promise/for_each.h +13 -1
- data/src/core/lib/promise/if.h +4 -0
- data/src/core/lib/promise/latch.h +6 -3
- data/src/core/lib/promise/party.cc +33 -31
- data/src/core/lib/promise/party.h +142 -6
- data/src/core/lib/promise/poll.h +39 -13
- data/src/core/lib/promise/promise.h +4 -0
- data/src/core/lib/promise/seq.h +107 -7
- data/src/core/lib/promise/status_flag.h +196 -0
- data/src/core/lib/promise/try_join.h +132 -0
- data/src/core/lib/promise/try_seq.h +132 -10
- data/src/core/lib/resolver/endpoint_addresses.cc +0 -1
- data/src/core/lib/resolver/endpoint_addresses.h +48 -0
- data/src/core/lib/resource_quota/arena.h +2 -2
- data/src/core/lib/resource_quota/memory_quota.cc +57 -8
- data/src/core/lib/resource_quota/memory_quota.h +6 -0
- data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +14 -11
- data/src/core/lib/security/authorization/grpc_server_authz_filter.h +14 -5
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +4 -0
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +4 -0
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +28 -20
- data/src/core/lib/security/credentials/external/external_account_credentials.h +4 -0
- data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +4 -0
- data/src/core/lib/security/credentials/external/file_external_account_credentials.h +4 -0
- data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +4 -0
- data/src/core/lib/security/credentials/external/url_external_account_credentials.h +4 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +2 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +0 -3
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +12 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_crl_provider.cc +22 -5
- data/src/core/lib/security/credentials/tls/grpc_tls_crl_provider.h +1 -5
- data/src/core/lib/security/credentials/tls/tls_credentials.cc +16 -0
- data/src/core/lib/security/credentials/xds/xds_credentials.cc +21 -28
- data/src/core/lib/security/credentials/xds/xds_credentials.h +2 -4
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +4 -3
- data/src/core/lib/security/transport/auth_filters.h +71 -4
- data/src/core/lib/security/transport/client_auth_filter.cc +2 -4
- data/src/core/lib/security/transport/legacy_server_auth_filter.cc +244 -0
- data/src/core/lib/security/transport/server_auth_filter.cc +70 -90
- data/src/core/lib/slice/slice_buffer.h +3 -0
- data/src/core/lib/surface/builtins.cc +1 -1
- data/src/core/lib/surface/call.cc +683 -196
- data/src/core/lib/surface/call.h +26 -13
- data/src/core/lib/surface/call_trace.cc +42 -1
- data/src/core/lib/surface/channel.cc +0 -1
- data/src/core/lib/surface/channel.h +0 -6
- data/src/core/lib/surface/channel_init.h +26 -0
- data/src/core/lib/surface/init.cc +14 -8
- data/src/core/lib/surface/server.cc +256 -237
- data/src/core/lib/surface/server.h +26 -54
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/surface/wait_for_cq_end_op.h +94 -0
- data/src/core/lib/transport/call_final_info.cc +38 -0
- data/src/core/lib/transport/call_final_info.h +54 -0
- data/src/core/lib/transport/connectivity_state.cc +3 -2
- data/src/core/lib/transport/connectivity_state.h +4 -0
- data/src/core/lib/transport/metadata_batch.h +4 -4
- data/src/core/lib/transport/transport.cc +70 -19
- data/src/core/lib/transport/transport.h +395 -25
- data/src/core/plugin_registry/grpc_plugin_registry.cc +3 -0
- data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +0 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +1 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +65 -43
- data/src/ruby/ext/grpc/rb_channel_args.c +3 -1
- data/src/ruby/ext/grpc/rb_grpc.c +0 -1
- data/src/ruby/ext/grpc/rb_grpc.h +0 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/upb/upb/reflection/def_pool.h +2 -2
- data/third_party/zlib/adler32.c +5 -27
- data/third_party/zlib/compress.c +5 -16
- data/third_party/zlib/crc32.c +86 -162
- data/third_party/zlib/deflate.c +233 -336
- data/third_party/zlib/deflate.h +8 -8
- data/third_party/zlib/gzguts.h +11 -12
- data/third_party/zlib/infback.c +7 -23
- data/third_party/zlib/inffast.c +1 -4
- data/third_party/zlib/inffast.h +1 -1
- data/third_party/zlib/inflate.c +30 -99
- data/third_party/zlib/inftrees.c +6 -11
- data/third_party/zlib/inftrees.h +3 -3
- data/third_party/zlib/trees.c +224 -302
- data/third_party/zlib/uncompr.c +4 -12
- data/third_party/zlib/zconf.h +6 -2
- data/third_party/zlib/zlib.h +191 -188
- data/third_party/zlib/zutil.c +16 -44
- data/third_party/zlib/zutil.h +10 -10
- metadata +35 -13
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +0 -1173
- data/src/core/lib/event_engine/memory_allocator.cc +0 -74
- data/src/core/lib/transport/pid_controller.cc +0 -51
- data/src/core/lib/transport/pid_controller.h +0 -116
- data/third_party/upb/upb/collections/array.h +0 -17
- data/third_party/upb/upb/collections/map.h +0 -17
- data/third_party/upb/upb/upb.hpp +0 -18
@@ -0,0 +1,214 @@
|
|
1
|
+
// Copyright 2015 gRPC authors.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
#ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H
|
16
|
+
#define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H
|
17
|
+
|
18
|
+
#include <grpc/support/port_platform.h>
|
19
|
+
|
20
|
+
#include <cstdint>
|
21
|
+
#include <string>
|
22
|
+
#include <vector>
|
23
|
+
|
24
|
+
#include "absl/status/statusor.h"
|
25
|
+
#include "absl/strings/string_view.h"
|
26
|
+
#include "absl/types/span.h"
|
27
|
+
#include "absl/types/variant.h"
|
28
|
+
|
29
|
+
#include "src/core/lib/slice/slice.h"
|
30
|
+
#include "src/core/lib/slice/slice_buffer.h"
|
31
|
+
|
32
|
+
namespace grpc_core {
|
33
|
+
|
34
|
+
///////////////////////////////////////////////////////////////////////////////
|
35
|
+
// Frame types
|
36
|
+
//
|
37
|
+
// Define structs for each kind of frame that chttp2 reasons about.
|
38
|
+
//
|
39
|
+
// Each struct gets the members defined by the HTTP/2 spec for that frame type
|
40
|
+
// *that the semantic layers of chttp2 neead to reason about*.
|
41
|
+
//
|
42
|
+
// That means, for instance, that we drop padding and prioritization data from
|
43
|
+
// these structs, as they are handled by the HTTP/2 framing layer and are
|
44
|
+
// meaningless to the semantic layers above.
|
45
|
+
//
|
46
|
+
// If a frame type is associated with a stream, it has a stream_id member.
|
47
|
+
// If that frame type is only used at the channel layer it does not.
|
48
|
+
//
|
49
|
+
// Instead of carrying bitfields of flags like the wire format, we instead
|
50
|
+
// declare a bool per flag to make producing/consuming code easier to write.
|
51
|
+
//
|
52
|
+
// Equality operators are defined for use in unit tests.
|
53
|
+
|
54
|
+
// DATA frame
|
55
|
+
struct Http2DataFrame {
|
56
|
+
uint32_t stream_id = 0;
|
57
|
+
bool end_stream = false;
|
58
|
+
SliceBuffer payload;
|
59
|
+
|
60
|
+
bool operator==(const Http2DataFrame& other) const {
|
61
|
+
return stream_id == other.stream_id && end_stream == other.end_stream &&
|
62
|
+
payload.JoinIntoString() == other.payload.JoinIntoString();
|
63
|
+
}
|
64
|
+
};
|
65
|
+
|
66
|
+
// HEADER frame
|
67
|
+
struct Http2HeaderFrame {
|
68
|
+
uint32_t stream_id = 0;
|
69
|
+
bool end_headers = false;
|
70
|
+
bool end_stream = false;
|
71
|
+
SliceBuffer payload;
|
72
|
+
|
73
|
+
bool operator==(const Http2HeaderFrame& other) const {
|
74
|
+
return stream_id == other.stream_id && end_headers == other.end_headers &&
|
75
|
+
end_stream == other.end_stream &&
|
76
|
+
payload.JoinIntoString() == other.payload.JoinIntoString();
|
77
|
+
}
|
78
|
+
};
|
79
|
+
|
80
|
+
// CONTINUATION frame
|
81
|
+
struct Http2ContinuationFrame {
|
82
|
+
uint32_t stream_id = 0;
|
83
|
+
bool end_headers = false;
|
84
|
+
SliceBuffer payload;
|
85
|
+
|
86
|
+
bool operator==(const Http2ContinuationFrame& other) const {
|
87
|
+
return stream_id == other.stream_id && end_headers == other.end_headers &&
|
88
|
+
payload.JoinIntoString() == other.payload.JoinIntoString();
|
89
|
+
}
|
90
|
+
};
|
91
|
+
|
92
|
+
// RST_STREAM frame
|
93
|
+
struct Http2RstStreamFrame {
|
94
|
+
uint32_t stream_id = 0;
|
95
|
+
uint32_t error_code = 0;
|
96
|
+
|
97
|
+
bool operator==(const Http2RstStreamFrame& other) const {
|
98
|
+
return stream_id == other.stream_id && error_code == other.error_code;
|
99
|
+
}
|
100
|
+
};
|
101
|
+
|
102
|
+
// SETTINGS frame
|
103
|
+
struct Http2SettingsFrame {
|
104
|
+
struct Setting {
|
105
|
+
Setting(uint16_t id, uint32_t value) : id(id), value(value) {}
|
106
|
+
|
107
|
+
uint16_t id;
|
108
|
+
uint32_t value;
|
109
|
+
|
110
|
+
bool operator==(const Setting& other) const {
|
111
|
+
return id == other.id && value == other.value;
|
112
|
+
}
|
113
|
+
};
|
114
|
+
bool ack = false;
|
115
|
+
std::vector<Setting> settings;
|
116
|
+
|
117
|
+
bool operator==(const Http2SettingsFrame& other) const {
|
118
|
+
return ack == other.ack && settings == other.settings;
|
119
|
+
}
|
120
|
+
};
|
121
|
+
|
122
|
+
// PING frame
|
123
|
+
struct Http2PingFrame {
|
124
|
+
bool ack = false;
|
125
|
+
uint64_t opaque = 0;
|
126
|
+
|
127
|
+
bool operator==(const Http2PingFrame& other) const {
|
128
|
+
return ack == other.ack && opaque == other.opaque;
|
129
|
+
}
|
130
|
+
};
|
131
|
+
|
132
|
+
// GOAWAY frame
|
133
|
+
struct Http2GoawayFrame {
|
134
|
+
uint32_t last_stream_id = 0;
|
135
|
+
uint32_t error_code = 0;
|
136
|
+
Slice debug_data;
|
137
|
+
|
138
|
+
bool operator==(const Http2GoawayFrame& other) const {
|
139
|
+
return last_stream_id == other.last_stream_id &&
|
140
|
+
error_code == other.error_code &&
|
141
|
+
debug_data.as_string_view() == other.debug_data.as_string_view();
|
142
|
+
}
|
143
|
+
};
|
144
|
+
|
145
|
+
// WINDOW_UPDATE frame
|
146
|
+
struct Http2WindowUpdateFrame {
|
147
|
+
uint32_t stream_id;
|
148
|
+
uint32_t increment;
|
149
|
+
|
150
|
+
bool operator==(const Http2WindowUpdateFrame& other) const {
|
151
|
+
return stream_id == other.stream_id && increment == other.increment;
|
152
|
+
}
|
153
|
+
};
|
154
|
+
|
155
|
+
// Type of frame was unknown (and should be ignored)
|
156
|
+
struct Http2UnknownFrame {
|
157
|
+
bool operator==(const Http2UnknownFrame&) const { return true; }
|
158
|
+
};
|
159
|
+
|
160
|
+
///////////////////////////////////////////////////////////////////////////////
|
161
|
+
// Frame variant
|
162
|
+
//
|
163
|
+
// A union of all the frame types above, so that we may pass around an
|
164
|
+
// arbitrary frame between layers as appropriate.
|
165
|
+
using Http2Frame =
|
166
|
+
absl::variant<Http2DataFrame, Http2HeaderFrame, Http2ContinuationFrame,
|
167
|
+
Http2RstStreamFrame, Http2SettingsFrame, Http2PingFrame,
|
168
|
+
Http2GoawayFrame, Http2WindowUpdateFrame, Http2UnknownFrame>;
|
169
|
+
|
170
|
+
///////////////////////////////////////////////////////////////////////////////
|
171
|
+
// Frame header
|
172
|
+
//
|
173
|
+
// Define a struct for the frame header.
|
174
|
+
// Parsing this type is the first step in parsing a frame.
|
175
|
+
// No validation on the header is done during parsing - the fields should be
|
176
|
+
// instead interpreted by the frame type parser.
|
177
|
+
struct Http2FrameHeader {
|
178
|
+
uint32_t length;
|
179
|
+
uint8_t type;
|
180
|
+
uint8_t flags;
|
181
|
+
uint32_t stream_id;
|
182
|
+
// Serialize header to 9 byte long buffer output
|
183
|
+
// Crashes if length > 16777215 (as this is unencodable)
|
184
|
+
void Serialize(uint8_t* output) const;
|
185
|
+
// Parse header from 9 byte long buffer input
|
186
|
+
static Http2FrameHeader Parse(const uint8_t* input);
|
187
|
+
std::string ToString() const;
|
188
|
+
|
189
|
+
bool operator==(const Http2FrameHeader& other) const {
|
190
|
+
return length == other.length && type == other.type &&
|
191
|
+
flags == other.flags && stream_id == other.stream_id;
|
192
|
+
}
|
193
|
+
};
|
194
|
+
|
195
|
+
///////////////////////////////////////////////////////////////////////////////
|
196
|
+
// Parsing & serialization
|
197
|
+
|
198
|
+
// Given a frame header and a payload, parse the payload into a frame and
|
199
|
+
// return it.
|
200
|
+
// If this function returns an error, that should be considered a connection
|
201
|
+
// error.
|
202
|
+
// If a frame should simply be ignored, this function returns a
|
203
|
+
// Http2UnknownFrame.
|
204
|
+
// It is expected that hdr.length == payload.Length().
|
205
|
+
absl::StatusOr<Http2Frame> ParseFramePayload(const Http2FrameHeader& hdr,
|
206
|
+
SliceBuffer payload);
|
207
|
+
|
208
|
+
// Serialize frame and append to out, leaves frames in an unknown state (may
|
209
|
+
// move things out of frames)
|
210
|
+
void Serialize(absl::Span<Http2Frame> frames, SliceBuffer& out);
|
211
|
+
|
212
|
+
} // namespace grpc_core
|
213
|
+
|
214
|
+
#endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H
|
@@ -126,7 +126,7 @@ grpc_error_handle grpc_chttp2_rst_stream_parser_parse(void* parser,
|
|
126
126
|
grpc_core::StatusIntProperty::kHttp2Error,
|
127
127
|
static_cast<intptr_t>(reason));
|
128
128
|
}
|
129
|
-
if (
|
129
|
+
if (!t->is_client &&
|
130
130
|
absl::Bernoulli(t->bitgen, t->ping_on_rst_stream_percent / 100.0)) {
|
131
131
|
++t->num_pending_induced_frames;
|
132
132
|
t->ping_callbacks.RequestPing();
|
@@ -33,6 +33,7 @@
|
|
33
33
|
|
34
34
|
#include "src/core/ext/transport/chttp2/transport/flow_control.h"
|
35
35
|
#include "src/core/ext/transport/chttp2/transport/frame_goaway.h"
|
36
|
+
#include "src/core/ext/transport/chttp2/transport/http2_settings.h"
|
36
37
|
#include "src/core/ext/transport/chttp2/transport/http_trace.h"
|
37
38
|
#include "src/core/ext/transport/chttp2/transport/internal.h"
|
38
39
|
#include "src/core/ext/transport/chttp2/transport/legacy_frame.h"
|
@@ -55,38 +56,6 @@ static uint8_t* fill_header(uint8_t* out, uint32_t length, uint8_t flags) {
|
|
55
56
|
return out;
|
56
57
|
}
|
57
58
|
|
58
|
-
grpc_slice grpc_chttp2_settings_create(uint32_t* old_settings,
|
59
|
-
const uint32_t* new_settings,
|
60
|
-
uint32_t force_mask, size_t count) {
|
61
|
-
size_t i;
|
62
|
-
uint32_t n = 0;
|
63
|
-
grpc_slice output;
|
64
|
-
uint8_t* p;
|
65
|
-
|
66
|
-
for (i = 0; i < count; i++) {
|
67
|
-
n += (new_settings[i] != old_settings[i] || (force_mask & (1u << i)) != 0);
|
68
|
-
}
|
69
|
-
|
70
|
-
output = GRPC_SLICE_MALLOC(9 + 6 * n);
|
71
|
-
p = fill_header(GRPC_SLICE_START_PTR(output), 6 * n, 0);
|
72
|
-
|
73
|
-
for (i = 0; i < count; i++) {
|
74
|
-
if (new_settings[i] != old_settings[i] || (force_mask & (1u << i)) != 0) {
|
75
|
-
*p++ = static_cast<uint8_t>(grpc_setting_id_to_wire_id[i] >> 8);
|
76
|
-
*p++ = static_cast<uint8_t>(grpc_setting_id_to_wire_id[i]);
|
77
|
-
*p++ = static_cast<uint8_t>(new_settings[i] >> 24);
|
78
|
-
*p++ = static_cast<uint8_t>(new_settings[i] >> 16);
|
79
|
-
*p++ = static_cast<uint8_t>(new_settings[i] >> 8);
|
80
|
-
*p++ = static_cast<uint8_t>(new_settings[i]);
|
81
|
-
old_settings[i] = new_settings[i];
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
GPR_ASSERT(p == GRPC_SLICE_END_PTR(output));
|
86
|
-
|
87
|
-
return output;
|
88
|
-
}
|
89
|
-
|
90
59
|
grpc_slice grpc_chttp2_settings_ack_create(void) {
|
91
60
|
grpc_slice output = GRPC_SLICE_MALLOC(9);
|
92
61
|
fill_header(GRPC_SLICE_START_PTR(output), 0, GRPC_CHTTP2_FLAG_ACK);
|
@@ -95,10 +64,9 @@ grpc_slice grpc_chttp2_settings_ack_create(void) {
|
|
95
64
|
|
96
65
|
grpc_error_handle grpc_chttp2_settings_parser_begin_frame(
|
97
66
|
grpc_chttp2_settings_parser* parser, uint32_t length, uint8_t flags,
|
98
|
-
|
99
|
-
parser->target_settings = settings;
|
100
|
-
|
101
|
-
GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t));
|
67
|
+
grpc_core::Http2Settings& settings) {
|
68
|
+
parser->target_settings = &settings;
|
69
|
+
parser->incoming_settings.Init(settings);
|
102
70
|
parser->is_ack = 0;
|
103
71
|
parser->state = GRPC_CHTTP2_SPS_ID0;
|
104
72
|
if (flags == GRPC_CHTTP2_FLAG_ACK) {
|
@@ -125,7 +93,6 @@ grpc_error_handle grpc_chttp2_settings_parser_parse(void* p,
|
|
125
93
|
static_cast<grpc_chttp2_settings_parser*>(p);
|
126
94
|
const uint8_t* cur = GRPC_SLICE_START_PTR(slice);
|
127
95
|
const uint8_t* end = GRPC_SLICE_END_PTR(slice);
|
128
|
-
grpc_chttp2_setting_id id;
|
129
96
|
|
130
97
|
if (parser->is_ack) {
|
131
98
|
return absl::OkStatus();
|
@@ -137,8 +104,7 @@ grpc_error_handle grpc_chttp2_settings_parser_parse(void* p,
|
|
137
104
|
if (cur == end) {
|
138
105
|
parser->state = GRPC_CHTTP2_SPS_ID0;
|
139
106
|
if (is_last) {
|
140
|
-
|
141
|
-
GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t));
|
107
|
+
*parser->target_settings = *parser->incoming_settings;
|
142
108
|
t->num_pending_induced_frames++;
|
143
109
|
grpc_slice_buffer_add(&t->qbuf, grpc_chttp2_settings_ack_create());
|
144
110
|
grpc_chttp2_initiate_write(t,
|
@@ -187,7 +153,7 @@ grpc_error_handle grpc_chttp2_settings_parser_parse(void* p,
|
|
187
153
|
parser->value |= (static_cast<uint32_t>(*cur)) << 8;
|
188
154
|
cur++;
|
189
155
|
ABSL_FALLTHROUGH_INTENDED;
|
190
|
-
case GRPC_CHTTP2_SPS_VAL3:
|
156
|
+
case GRPC_CHTTP2_SPS_VAL3: {
|
191
157
|
if (cur == end) {
|
192
158
|
parser->state = GRPC_CHTTP2_SPS_VAL3;
|
193
159
|
return absl::OkStatus();
|
@@ -197,47 +163,35 @@ grpc_error_handle grpc_chttp2_settings_parser_parse(void* p,
|
|
197
163
|
parser->value |= *cur;
|
198
164
|
cur++;
|
199
165
|
|
200
|
-
if (
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
case GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE:
|
210
|
-
grpc_chttp2_goaway_append(
|
211
|
-
t->last_new_stream_id, sp->error_value,
|
212
|
-
grpc_slice_from_static_string("HTTP2 settings error"),
|
213
|
-
&t->qbuf);
|
214
|
-
return GRPC_ERROR_CREATE(absl::StrFormat(
|
215
|
-
"invalid value %u passed for %s", parser->value, sp->name));
|
216
|
-
}
|
217
|
-
}
|
218
|
-
if (id == GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE &&
|
219
|
-
parser->incoming_settings[id] != parser->value) {
|
220
|
-
t->initial_window_update += static_cast<int64_t>(parser->value) -
|
221
|
-
parser->incoming_settings[id];
|
222
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) ||
|
223
|
-
GRPC_TRACE_FLAG_ENABLED(grpc_flowctl_trace)) {
|
224
|
-
gpr_log(GPR_INFO, "%p[%s] adding %d for initial_window change", t,
|
225
|
-
t->is_client ? "cli" : "svr",
|
226
|
-
static_cast<int>(t->initial_window_update));
|
227
|
-
}
|
228
|
-
}
|
229
|
-
parser->incoming_settings[id] = parser->value;
|
230
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
|
231
|
-
gpr_log(GPR_INFO, "CHTTP2:%s:%s: got setting %s = %d",
|
232
|
-
t->is_client ? "CLI" : "SVR",
|
233
|
-
std::string(t->peer_string.as_string_view()).c_str(),
|
234
|
-
sp->name, parser->value);
|
166
|
+
if (parser->id == grpc_core::Http2Settings::kInitialWindowSizeWireId) {
|
167
|
+
t->initial_window_update +=
|
168
|
+
static_cast<int64_t>(parser->value) -
|
169
|
+
parser->incoming_settings->initial_window_size();
|
170
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) ||
|
171
|
+
GRPC_TRACE_FLAG_ENABLED(grpc_flowctl_trace)) {
|
172
|
+
gpr_log(GPR_INFO, "%p[%s] adding %d for initial_window change", t,
|
173
|
+
t->is_client ? "cli" : "svr",
|
174
|
+
static_cast<int>(t->initial_window_update));
|
235
175
|
}
|
236
|
-
} else if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
|
237
|
-
gpr_log(GPR_DEBUG, "CHTTP2: Ignoring unknown setting %d (value %d)",
|
238
|
-
parser->id, parser->value);
|
239
176
|
}
|
240
|
-
|
177
|
+
auto error =
|
178
|
+
parser->incoming_settings->Apply(parser->id, parser->value);
|
179
|
+
if (error != GRPC_HTTP2_NO_ERROR) {
|
180
|
+
grpc_chttp2_goaway_append(
|
181
|
+
t->last_new_stream_id, error,
|
182
|
+
grpc_slice_from_static_string("HTTP2 settings error"), &t->qbuf);
|
183
|
+
return GRPC_ERROR_CREATE(absl::StrFormat(
|
184
|
+
"invalid value %u passed for %s", parser->value,
|
185
|
+
grpc_core::Http2Settings::WireIdToName(parser->id).c_str()));
|
186
|
+
}
|
187
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
|
188
|
+
gpr_log(GPR_INFO, "CHTTP2:%s:%s: got setting %s = %d",
|
189
|
+
t->is_client ? "CLI" : "SVR",
|
190
|
+
std::string(t->peer_string.as_string_view()).c_str(),
|
191
|
+
grpc_core::Http2Settings::WireIdToName(parser->id).c_str(),
|
192
|
+
parser->value);
|
193
|
+
}
|
194
|
+
} break;
|
241
195
|
}
|
242
196
|
}
|
243
197
|
}
|
@@ -28,6 +28,7 @@
|
|
28
28
|
|
29
29
|
#include "src/core/ext/transport/chttp2/transport/http2_settings.h"
|
30
30
|
#include "src/core/ext/transport/chttp2/transport/legacy_frame.h"
|
31
|
+
#include "src/core/lib/gprpp/manual_constructor.h"
|
31
32
|
#include "src/core/lib/iomgr/error.h"
|
32
33
|
|
33
34
|
typedef enum {
|
@@ -41,22 +42,18 @@ typedef enum {
|
|
41
42
|
|
42
43
|
struct grpc_chttp2_settings_parser {
|
43
44
|
grpc_chttp2_settings_parse_state state;
|
44
|
-
|
45
|
+
grpc_core::Http2Settings* target_settings;
|
46
|
+
grpc_core::ManualConstructor<grpc_core::Http2Settings> incoming_settings;
|
45
47
|
uint8_t is_ack;
|
46
48
|
uint16_t id;
|
47
49
|
uint32_t value;
|
48
|
-
uint32_t incoming_settings[GRPC_CHTTP2_NUM_SETTINGS];
|
49
50
|
};
|
50
|
-
// Create a settings frame by diffing old & new, and updating old to be new
|
51
|
-
grpc_slice grpc_chttp2_settings_create(uint32_t* old_settings,
|
52
|
-
const uint32_t* new_settings,
|
53
|
-
uint32_t force_mask, size_t count);
|
54
51
|
// Create an ack settings frame
|
55
52
|
grpc_slice grpc_chttp2_settings_ack_create(void);
|
56
53
|
|
57
54
|
grpc_error_handle grpc_chttp2_settings_parser_begin_frame(
|
58
55
|
grpc_chttp2_settings_parser* parser, uint32_t length, uint8_t flags,
|
59
|
-
|
56
|
+
grpc_core::Http2Settings& settings);
|
60
57
|
grpc_error_handle grpc_chttp2_settings_parser_parse(void* parser,
|
61
58
|
grpc_chttp2_transport* t,
|
62
59
|
grpc_chttp2_stream* s,
|
@@ -91,14 +91,12 @@ constexpr Base64InverseTable kBase64InverseTable;
|
|
91
91
|
class HPackParser::Input {
|
92
92
|
public:
|
93
93
|
Input(grpc_slice_refcount* current_slice_refcount, const uint8_t* begin,
|
94
|
-
const uint8_t* end, absl::BitGenRef bitsrc,
|
95
|
-
HpackParseResult& frame_error, HpackParseResult& field_error)
|
94
|
+
const uint8_t* end, absl::BitGenRef bitsrc, HpackParseResult& error)
|
96
95
|
: current_slice_refcount_(current_slice_refcount),
|
97
96
|
begin_(begin),
|
98
97
|
end_(end),
|
99
98
|
frontier_(begin),
|
100
|
-
|
101
|
-
field_error_(field_error),
|
99
|
+
error_(error),
|
102
100
|
bitsrc_(bitsrc) {}
|
103
101
|
|
104
102
|
// If input is backed by a slice, retrieve its refcount. If not, return
|
@@ -217,18 +215,14 @@ class HPackParser::Input {
|
|
217
215
|
|
218
216
|
// Check if we saw an EOF
|
219
217
|
bool eof_error() const {
|
220
|
-
return min_progress_size_ != 0 ||
|
221
|
-
}
|
222
|
-
|
223
|
-
// Reset the field error to be ok
|
224
|
-
void ClearFieldError() {
|
225
|
-
if (field_error_.ok()) return;
|
226
|
-
field_error_ = HpackParseResult();
|
218
|
+
return min_progress_size_ != 0 || error_.connection_error();
|
227
219
|
}
|
228
220
|
|
229
221
|
// Minimum number of bytes to unstuck the current parse
|
230
222
|
size_t min_progress_size() const { return min_progress_size_; }
|
231
223
|
|
224
|
+
bool has_error() const { return !error_.ok(); }
|
225
|
+
|
232
226
|
// Set the current error - tweaks the error to include a stream id so that
|
233
227
|
// chttp2 does not close the connection.
|
234
228
|
// Intended for errors that are specific to a stream and recoverable.
|
@@ -252,7 +246,10 @@ class HPackParser::Input {
|
|
252
246
|
// read prior to being able to get further in this parse.
|
253
247
|
void UnexpectedEOF(size_t min_progress_size) {
|
254
248
|
GPR_ASSERT(min_progress_size > 0);
|
255
|
-
if (
|
249
|
+
if (min_progress_size_ != 0 || error_.connection_error()) {
|
250
|
+
GPR_DEBUG_ASSERT(eof_error());
|
251
|
+
return;
|
252
|
+
}
|
256
253
|
// Set min progress size, taking into account bytes parsed already but not
|
257
254
|
// consumed.
|
258
255
|
min_progress_size_ = min_progress_size + (begin_ - frontier_);
|
@@ -305,18 +302,13 @@ class HPackParser::Input {
|
|
305
302
|
// Do not use this directly, instead use SetErrorAndContinueParsing or
|
306
303
|
// SetErrorAndStopParsing.
|
307
304
|
void SetError(HpackParseResult error) {
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
void SetErrorFor(HpackParseResult& error, HpackParseResult new_error) {
|
313
|
-
if (!error.ok() || min_progress_size_ > 0) {
|
314
|
-
if (new_error.connection_error() && !error.connection_error()) {
|
315
|
-
error = std::move(new_error); // connection errors dominate
|
305
|
+
if (!error_.ok() || min_progress_size_ > 0) {
|
306
|
+
if (error.connection_error() && !error_.connection_error()) {
|
307
|
+
error_ = std::move(error); // connection errors dominate
|
316
308
|
}
|
317
309
|
return;
|
318
310
|
}
|
319
|
-
|
311
|
+
error_ = std::move(error);
|
320
312
|
}
|
321
313
|
|
322
314
|
// Refcount if we are backed by a slice
|
@@ -328,8 +320,7 @@ class HPackParser::Input {
|
|
328
320
|
// Frontier denotes the first byte past successfully processed input
|
329
321
|
const uint8_t* frontier_;
|
330
322
|
// Current error
|
331
|
-
HpackParseResult&
|
332
|
-
HpackParseResult& field_error_;
|
323
|
+
HpackParseResult& error_;
|
333
324
|
// If the error was EOF, we flag it here by noting how many more bytes would
|
334
325
|
// be needed to make progress
|
335
326
|
size_t min_progress_size_ = 0;
|
@@ -606,7 +597,6 @@ class HPackParser::Parser {
|
|
606
597
|
bool ParseTop() {
|
607
598
|
GPR_DEBUG_ASSERT(state_.parse_state == ParseState::kTop);
|
608
599
|
auto cur = *input_->Next();
|
609
|
-
input_->ClearFieldError();
|
610
600
|
switch (cur >> 4) {
|
611
601
|
// Literal header not indexed - First byte format: 0000xxxx
|
612
602
|
// Literal header never indexed - First byte format: 0001xxxx
|
@@ -712,7 +702,7 @@ class HPackParser::Parser {
|
|
712
702
|
break;
|
713
703
|
}
|
714
704
|
gpr_log(
|
715
|
-
|
705
|
+
GPR_DEBUG, "HTTP:%d:%s:%s: %s%s", log_info_.stream_id, type,
|
716
706
|
log_info_.is_client ? "CLI" : "SVR", memento.md.DebugString().c_str(),
|
717
707
|
memento.parse_status == nullptr
|
718
708
|
? ""
|
@@ -961,10 +951,11 @@ class HPackParser::Parser {
|
|
961
951
|
state_.string_length)
|
962
952
|
: String::Parse(input_, state_.is_string_huff_compressed,
|
963
953
|
state_.string_length);
|
954
|
+
HpackParseResult& status = state_.frame_error;
|
964
955
|
absl::string_view key_string;
|
965
956
|
if (auto* s = absl::get_if<Slice>(&state_.key)) {
|
966
957
|
key_string = s->as_string_view();
|
967
|
-
if (
|
958
|
+
if (status.ok()) {
|
968
959
|
auto r = ValidateKey(key_string);
|
969
960
|
if (r != ValidateMetadataResult::kOk) {
|
970
961
|
input_->SetErrorAndContinueParsing(
|
@@ -974,7 +965,7 @@ class HPackParser::Parser {
|
|
974
965
|
} else {
|
975
966
|
const auto* memento = absl::get<const HPackTable::Memento*>(state_.key);
|
976
967
|
key_string = memento->md.key();
|
977
|
-
if (
|
968
|
+
if (status.ok() && memento->parse_status != nullptr) {
|
978
969
|
input_->SetErrorAndContinueParsing(*memento->parse_status);
|
979
970
|
}
|
980
971
|
}
|
@@ -1001,16 +992,16 @@ class HPackParser::Parser {
|
|
1001
992
|
key_string.size() + value.wire_size + hpack_constants::kEntryOverhead;
|
1002
993
|
auto md = grpc_metadata_batch::Parse(
|
1003
994
|
key_string, std::move(value_slice), state_.add_to_table, transport_size,
|
1004
|
-
[key_string, this](absl::string_view message, const Slice&) {
|
1005
|
-
if (!
|
995
|
+
[key_string, &status, this](absl::string_view message, const Slice&) {
|
996
|
+
if (!status.ok()) return;
|
1006
997
|
input_->SetErrorAndContinueParsing(
|
1007
998
|
HpackParseResult::MetadataParseError(key_string));
|
1008
999
|
gpr_log(GPR_ERROR, "Error parsing '%s' metadata: %s",
|
1009
1000
|
std::string(key_string).c_str(),
|
1010
1001
|
std::string(message).c_str());
|
1011
1002
|
});
|
1012
|
-
HPackTable::Memento memento{
|
1013
|
-
|
1003
|
+
HPackTable::Memento memento{std::move(md),
|
1004
|
+
status.PersistentStreamErrorOrNullptr()};
|
1014
1005
|
input_->UpdateFrontier();
|
1015
1006
|
state_.parse_state = ParseState::kTop;
|
1016
1007
|
if (state_.add_to_table) {
|
@@ -1172,13 +1163,13 @@ grpc_error_handle HPackParser::Parse(
|
|
1172
1163
|
std::vector<uint8_t> buffer = std::move(unparsed_bytes_);
|
1173
1164
|
return ParseInput(
|
1174
1165
|
Input(nullptr, buffer.data(), buffer.data() + buffer.size(), bitsrc,
|
1175
|
-
state_.frame_error
|
1166
|
+
state_.frame_error),
|
1176
1167
|
is_last, call_tracer);
|
1177
1168
|
}
|
1178
|
-
return ParseInput(
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1169
|
+
return ParseInput(
|
1170
|
+
Input(slice.refcount, GRPC_SLICE_START_PTR(slice),
|
1171
|
+
GRPC_SLICE_END_PTR(slice), bitsrc, state_.frame_error),
|
1172
|
+
is_last, call_tracer);
|
1182
1173
|
}
|
1183
1174
|
|
1184
1175
|
grpc_error_handle HPackParser::ParseInput(
|
@@ -236,8 +236,6 @@ class HPackParser {
|
|
236
236
|
HPackTable hpack_table;
|
237
237
|
// Error so far for this frame (set by class Input)
|
238
238
|
HpackParseResult frame_error;
|
239
|
-
// Error so far for this field (set by class Input)
|
240
|
-
HpackParseResult field_error;
|
241
239
|
// Length of frame so far.
|
242
240
|
uint32_t frame_length = 0;
|
243
241
|
// Length of the string being parsed
|