grpc 0.14.1 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +1398 -817
- data/include/grpc/compression.h +2 -1
- data/include/grpc/grpc.h +10 -1
- data/include/grpc/grpc_cronet.h +51 -0
- data/include/grpc/grpc_posix.h +70 -0
- data/include/grpc/impl/codegen/atm.h +2 -2
- data/include/grpc/impl/codegen/{atm_win32.h → atm_windows.h} +3 -3
- data/include/grpc/impl/codegen/compression_types.h +39 -5
- data/include/grpc/impl/codegen/connectivity_state.h +1 -1
- data/include/grpc/impl/codegen/grpc_types.h +10 -0
- data/include/grpc/impl/codegen/log.h +2 -1
- data/include/grpc/impl/codegen/port_platform.h +30 -12
- data/include/grpc/impl/codegen/slice_buffer.h +2 -3
- data/include/grpc/impl/codegen/sync.h +2 -2
- data/include/grpc/impl/codegen/{sync_win32.h → sync_windows.h} +3 -3
- data/include/grpc/support/{sync_win32.h → atm_windows.h} +4 -4
- data/include/grpc/support/avl.h +5 -0
- data/include/grpc/support/{log_win32.h → log_windows.h} +3 -3
- data/include/grpc/support/string_util.h +2 -1
- data/include/grpc/support/{atm_win32.h → sync_windows.h} +4 -4
- data/src/core/ext/census/gen/census.pb.c +179 -0
- data/src/core/ext/census/gen/census.pb.h +294 -0
- data/src/core/ext/census/grpc_filter.c +11 -7
- data/src/core/ext/client_config/channel_connectivity.c +28 -14
- data/src/core/ext/client_config/client_channel.c +77 -53
- data/src/core/ext/client_config/connector.h +1 -1
- data/src/core/ext/client_config/lb_policy.c +9 -6
- data/src/core/ext/client_config/lb_policy.h +9 -5
- data/src/core/ext/client_config/subchannel.c +58 -39
- data/src/core/ext/client_config/subchannel.h +3 -2
- data/src/core/ext/client_config/subchannel_call_holder.c +34 -19
- data/src/core/ext/client_config/subchannel_call_holder.h +2 -1
- data/src/core/ext/client_config/subchannel_index.c +20 -9
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +7 -7
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.h +5 -5
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/{v0 → v1}/load_balancer.pb.c +29 -30
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +178 -0
- data/src/core/ext/lb_policy/pick_first/pick_first.c +65 -45
- data/src/core/ext/lb_policy/round_robin/round_robin.c +84 -43
- data/src/core/ext/load_reporting/load_reporting.c +133 -0
- data/src/core/ext/load_reporting/load_reporting.h +75 -0
- data/src/core/ext/load_reporting/load_reporting_filter.c +151 -0
- data/src/core/ext/load_reporting/load_reporting_filter.h +41 -0
- data/src/core/ext/resolver/dns/native/dns_resolver.c +22 -8
- data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +2 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +4 -4
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +95 -0
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +14 -18
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +49 -24
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +82 -0
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +104 -60
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +232 -0
- data/src/{ruby/ext/grpc/rb_signal.c → core/ext/transport/chttp2/transport/bin_decoder.h} +27 -31
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +481 -260
- data/src/core/ext/transport/chttp2/transport/frame.h +1 -7
- data/src/core/ext/transport/chttp2/transport/frame_data.c +44 -27
- data/src/core/ext/transport/chttp2/transport/frame_data.h +6 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +23 -17
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +12 -7
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -3
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +25 -12
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +23 -21
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -9
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +365 -287
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +8 -6
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +24 -20
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +5 -4
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +1 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +1 -0
- data/src/core/ext/transport/chttp2/transport/internal.h +34 -32
- data/src/core/ext/transport/chttp2/transport/parsing.c +296 -212
- data/src/core/ext/transport/chttp2/transport/writing.c +12 -9
- data/src/core/lib/channel/channel_args.c +26 -12
- data/src/core/lib/channel/channel_args.h +1 -1
- data/src/core/lib/channel/channel_stack.c +12 -8
- data/src/core/lib/channel/channel_stack.h +27 -11
- data/src/core/lib/channel/channel_stack_builder.c +2 -2
- data/src/core/lib/channel/compress_filter.c +26 -31
- data/src/core/lib/channel/compress_filter.h +4 -4
- data/src/core/lib/channel/connected_channel.c +7 -5
- data/src/core/lib/channel/http_client_filter.c +34 -8
- data/src/core/lib/channel/http_client_filter.h +1 -1
- data/src/core/lib/channel/http_server_filter.c +21 -12
- data/src/core/lib/compression/{compression_algorithm.c → compression.c} +22 -21
- data/src/core/lib/http/httpcli.c +81 -59
- data/src/core/lib/http/httpcli.h +11 -15
- data/src/core/lib/http/httpcli_security_connector.c +5 -3
- data/src/core/lib/http/parser.c +127 -118
- data/src/core/lib/http/parser.h +11 -6
- data/src/core/lib/iomgr/closure.c +20 -16
- data/src/core/lib/iomgr/closure.h +19 -15
- data/src/core/lib/iomgr/endpoint.h +1 -1
- data/src/core/lib/iomgr/endpoint_pair_posix.c +2 -2
- data/src/core/lib/iomgr/error.c +535 -0
- data/src/core/lib/iomgr/error.h +192 -0
- data/src/core/lib/iomgr/ev_poll_and_epoll_posix.c +190 -83
- data/src/core/lib/iomgr/ev_poll_posix.c +1267 -0
- data/src/{ruby/ext/grpc/rb_signal.h → core/lib/iomgr/ev_poll_posix.h} +7 -5
- data/src/core/lib/iomgr/ev_posix.c +104 -14
- data/src/core/lib/iomgr/ev_posix.h +17 -7
- data/src/core/lib/iomgr/exec_ctx.c +25 -7
- data/src/core/lib/iomgr/exec_ctx.h +27 -8
- data/src/core/lib/iomgr/executor.c +2 -2
- data/src/core/lib/iomgr/executor.h +1 -1
- data/src/core/lib/iomgr/iocp_windows.c +2 -41
- data/src/core/lib/iomgr/iocp_windows.h +0 -8
- data/src/core/lib/iomgr/iomgr.c +5 -4
- data/src/core/lib/iomgr/iomgr_posix.c +5 -1
- data/src/core/lib/iomgr/iomgr_windows.c +1 -1
- data/src/core/lib/{support → iomgr}/load_file.c +15 -17
- data/src/core/lib/{support → iomgr}/load_file.h +8 -7
- data/src/core/lib/iomgr/polling_entity.c +104 -0
- data/src/core/lib/iomgr/polling_entity.h +81 -0
- data/src/core/lib/iomgr/pollset.h +6 -5
- data/src/core/lib/iomgr/pollset_set_windows.c +4 -1
- data/src/core/lib/iomgr/pollset_windows.c +10 -6
- data/src/core/lib/iomgr/resolve_address.h +5 -9
- data/src/core/lib/iomgr/resolve_address_posix.c +55 -38
- data/src/core/lib/iomgr/resolve_address_windows.c +51 -37
- data/src/core/lib/iomgr/sockaddr.h +2 -2
- data/src/core/lib/iomgr/{sockaddr_win32.h → sockaddr_windows.h} +3 -3
- data/src/core/lib/iomgr/socket_utils_common_posix.c +92 -45
- data/src/core/lib/iomgr/socket_utils_posix.h +19 -12
- data/src/core/lib/iomgr/socket_windows.c +61 -2
- data/src/core/lib/iomgr/socket_windows.h +13 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +54 -39
- data/src/core/lib/iomgr/tcp_client_windows.c +34 -34
- data/src/core/lib/iomgr/tcp_posix.c +43 -39
- data/src/core/lib/iomgr/tcp_server.h +5 -3
- data/src/core/lib/iomgr/tcp_server_posix.c +103 -64
- data/src/core/lib/iomgr/tcp_server_windows.c +114 -101
- data/src/core/lib/iomgr/tcp_windows.c +45 -50
- data/src/core/lib/iomgr/tcp_windows.h +1 -1
- data/src/core/lib/iomgr/timer.c +26 -13
- data/src/core/lib/iomgr/udp_server.c +28 -4
- data/src/core/lib/iomgr/udp_server.h +5 -1
- data/src/core/lib/iomgr/unix_sockets_posix.c +8 -7
- data/src/core/lib/iomgr/unix_sockets_posix.h +2 -1
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +4 -2
- data/src/core/lib/iomgr/wakeup_fd_eventfd.c +15 -5
- data/src/core/lib/iomgr/wakeup_fd_pipe.c +13 -9
- data/src/core/lib/iomgr/wakeup_fd_posix.c +6 -6
- data/src/core/lib/iomgr/wakeup_fd_posix.h +9 -6
- data/src/core/lib/iomgr/workqueue.h +5 -4
- data/src/core/lib/iomgr/workqueue_posix.c +40 -26
- data/src/core/lib/iomgr/workqueue_windows.c +2 -2
- data/src/core/lib/profiling/basic_timers.c +2 -2
- data/src/core/lib/security/{security_context.c → context/security_context.c} +1 -1
- data/src/core/lib/security/{security_context.h → context/security_context.h} +4 -4
- data/src/core/lib/security/credentials/composite/composite_credentials.c +263 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.h +72 -0
- data/src/core/lib/security/credentials/credentials.c +233 -0
- data/src/core/lib/security/{credentials.h → credentials/credentials.h} +19 -157
- data/src/core/lib/security/{credentials_metadata.c → credentials/credentials_metadata.c} +1 -1
- data/src/core/lib/security/credentials/fake/fake_credentials.c +139 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.h +56 -0
- data/src/core/lib/security/{credentials_posix.c → credentials/google_default/credentials_posix.c} +1 -1
- data/src/core/lib/security/{credentials_win32.c → credentials/google_default/credentials_windows.c} +3 -3
- data/src/core/lib/security/{google_default_credentials.c → credentials/google_default/google_default_credentials.c} +93 -35
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +46 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.c +85 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.h +44 -0
- data/src/core/lib/security/{json_token.c → credentials/jwt/json_token.c} +10 -101
- data/src/core/lib/security/{json_token.h → credentials/jwt/json_token.h} +3 -33
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +160 -0
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +62 -0
- data/src/core/lib/security/{jwt_verifier.c → credentials/jwt/jwt_verifier.c} +35 -15
- data/src/core/lib/security/{jwt_verifier.h → credentials/jwt/jwt_verifier.h} +3 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +433 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +109 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +129 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +45 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +240 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +48 -0
- data/src/core/lib/security/{auth_filters.h → transport/auth_filters.h} +3 -3
- data/src/core/lib/security/{client_auth_filter.c → transport/client_auth_filter.c} +27 -20
- data/src/core/lib/security/{handshake.c → transport/handshake.c} +77 -45
- data/src/core/lib/security/{handshake.h → transport/handshake.h} +9 -11
- data/src/core/lib/security/{secure_endpoint.c → transport/secure_endpoint.c} +19 -12
- data/src/core/lib/security/{secure_endpoint.h → transport/secure_endpoint.h} +3 -3
- data/src/core/lib/security/{security_connector.c → transport/security_connector.c} +26 -17
- data/src/core/lib/security/{security_connector.h → transport/security_connector.h} +8 -8
- data/src/core/lib/security/{server_auth_filter.c → transport/server_auth_filter.c} +24 -16
- data/src/core/lib/security/transport/tsi_error.c +40 -0
- data/src/core/lib/security/transport/tsi_error.h +42 -0
- data/src/core/lib/security/{b64.c → util/b64.c} +1 -1
- data/src/core/lib/security/{b64.h → util/b64.h} +3 -3
- data/src/core/lib/security/util/json_util.c +61 -0
- data/src/core/lib/security/util/json_util.h +55 -0
- data/src/core/lib/support/avl.c +11 -0
- data/src/core/lib/support/cpu_windows.c +2 -2
- data/src/core/lib/support/{env_win32.c → env_windows.c} +3 -3
- data/src/core/lib/support/log.c +3 -1
- data/src/core/lib/support/log_linux.c +2 -2
- data/src/core/lib/support/{log_win32.c → log_windows.c} +4 -4
- data/src/core/lib/support/murmur_hash.c +3 -5
- data/src/core/lib/support/string.c +10 -0
- data/src/core/lib/support/string.h +4 -0
- data/src/core/lib/support/{string_util_win32.c → string_util_windows.c} +3 -3
- data/src/core/lib/support/{string_win32.c → string_windows.c} +2 -2
- data/src/core/lib/support/{string_win32.h → string_windows.h} +5 -5
- data/src/core/lib/support/subprocess_windows.c +1 -1
- data/src/core/lib/support/{sync_win32.c → sync_windows.c} +2 -2
- data/src/core/lib/support/{thd_win32.c → thd_windows.c} +2 -2
- data/src/core/lib/support/{time_win32.c → time_windows.c} +2 -2
- data/src/core/lib/support/tmpfile_msys.c +1 -1
- data/src/core/lib/support/{tmpfile_win32.c → tmpfile_windows.c} +3 -3
- data/src/core/lib/surface/alarm.c +2 -2
- data/src/core/lib/surface/byte_buffer_reader.c +13 -6
- data/src/core/lib/surface/call.c +323 -123
- data/src/core/lib/surface/call.h +2 -0
- data/src/core/lib/surface/call_log_batch.c +1 -1
- data/src/core/lib/surface/channel.c +64 -15
- data/src/core/lib/surface/channel.h +9 -0
- data/src/core/lib/surface/channel_ping.c +3 -3
- data/src/core/lib/surface/completion_queue.c +75 -19
- data/src/core/lib/surface/completion_queue.h +7 -2
- data/src/core/lib/surface/init.c +2 -1
- data/src/core/lib/surface/init_secure.c +4 -4
- data/src/core/lib/surface/lame_client.c +12 -8
- data/src/core/lib/surface/server.c +213 -120
- data/src/core/lib/surface/server.h +1 -0
- data/src/core/lib/surface/version.c +1 -1
- data/src/core/lib/transport/connectivity_state.c +40 -18
- data/src/core/lib/transport/connectivity_state.h +4 -1
- data/src/core/lib/transport/metadata.c +23 -23
- data/src/core/lib/transport/metadata.h +4 -0
- data/src/core/lib/transport/metadata_batch.c +9 -0
- data/src/core/lib/transport/metadata_batch.h +3 -0
- data/src/core/lib/transport/static_metadata.c +6 -5
- data/src/core/lib/transport/static_metadata.h +64 -60
- data/src/core/lib/transport/transport.c +24 -12
- data/src/core/lib/transport/transport.h +6 -5
- data/src/core/lib/transport/transport_impl.h +4 -0
- data/src/core/lib/transport/transport_op_string.c +2 -2
- data/src/core/plugin_registry/grpc_plugin_registry.c +4 -0
- data/src/ruby/bin/math_services.rb +41 -2
- data/src/ruby/ext/grpc/rb_call.c +42 -40
- data/src/ruby/ext/grpc/rb_channel.c +1 -1
- data/src/ruby/ext/grpc/rb_completion_queue.c +59 -6
- data/src/ruby/ext/grpc/rb_completion_queue.h +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +1 -3
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +21 -5
- data/src/ruby/ext/grpc/rb_loader.c +1 -1
- data/src/ruby/ext/grpc/rb_server.c +5 -3
- data/src/ruby/lib/grpc.rb +0 -3
- data/src/ruby/lib/grpc/errors.rb +3 -2
- data/src/ruby/lib/grpc/generic/active_call.rb +32 -42
- data/src/ruby/lib/grpc/generic/bidi_call.rb +20 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +31 -54
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +4 -4
- data/src/ruby/lib/grpc/generic/rpc_server.rb +12 -23
- data/src/ruby/lib/grpc/generic/service.rb +8 -8
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_services.rb +30 -2
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb +34 -4
- data/src/ruby/pb/grpc/testing/metrics_services.rb +39 -2
- data/src/ruby/pb/src/proto/grpc/testing/empty.rb +15 -0
- data/src/ruby/pb/src/proto/grpc/testing/messages.rb +84 -0
- data/src/ruby/pb/src/proto/grpc/testing/test.rb +14 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services.rb +110 -0
- data/src/ruby/pb/test/client.rb +5 -2
- data/src/ruby/spec/generic/active_call_spec.rb +3 -2
- data/src/ruby/spec/generic/client_stub_spec.rb +27 -24
- data/src/ruby/spec/generic/rpc_desc_spec.rb +11 -11
- data/src/ruby/spec/generic/rpc_server_spec.rb +42 -61
- data/src/ruby/spec/pb/health/checker_spec.rb +3 -5
- metadata +86 -48
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h +0 -182
- data/src/core/lib/security/credentials.c +0 -1296
- data/src/ruby/lib/grpc/signals.rb +0 -69
@@ -34,11 +34,11 @@
|
|
34
34
|
#ifndef GRPC_CORE_LIB_CHANNEL_COMPRESS_FILTER_H
|
35
35
|
#define GRPC_CORE_LIB_CHANNEL_COMPRESS_FILTER_H
|
36
36
|
|
37
|
-
#include
|
37
|
+
#include <grpc/impl/codegen/compression_types.h>
|
38
38
|
|
39
|
-
#
|
39
|
+
#include "src/core/lib/channel/channel_stack.h"
|
40
40
|
|
41
|
-
extern int
|
41
|
+
extern int grpc_compression_trace;
|
42
42
|
|
43
43
|
/** Compression filter for outgoing data.
|
44
44
|
*
|
@@ -48,7 +48,7 @@ extern int grpc_compress_filter_trace;
|
|
48
48
|
* - Channel configuration, as established at channel creation time.
|
49
49
|
* - The metadata accompanying the outgoing data to be compressed. This is
|
50
50
|
* taken as a request only. We may choose not to honor it. The metadata key
|
51
|
-
* is given by \a
|
51
|
+
* is given by \a GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY.
|
52
52
|
*
|
53
53
|
* Compression can be disabled for concrete messages (for instance in order to
|
54
54
|
* prevent CRIME/BEAST type attacks) by having the GRPC_WRITE_NO_COMPRESS set in
|
@@ -93,16 +93,18 @@ static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
|
93
93
|
GPR_ASSERT(r == 0);
|
94
94
|
}
|
95
95
|
|
96
|
-
static void
|
97
|
-
|
96
|
+
static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
|
97
|
+
grpc_call_element *elem,
|
98
|
+
grpc_polling_entity *pollent) {
|
98
99
|
call_data *calld = elem->call_data;
|
99
100
|
channel_data *chand = elem->channel_data;
|
100
|
-
|
101
|
-
|
101
|
+
grpc_transport_set_pops(exec_ctx, chand->transport,
|
102
|
+
TRANSPORT_STREAM_FROM_CALL_DATA(calld), pollent);
|
102
103
|
}
|
103
104
|
|
104
105
|
/* Destructor for call_data */
|
105
106
|
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
107
|
+
const grpc_call_stats *stats,
|
106
108
|
void *and_free_memory) {
|
107
109
|
call_data *calld = elem->call_data;
|
108
110
|
channel_data *chand = elem->channel_data;
|
@@ -137,7 +139,7 @@ static const grpc_channel_filter connected_channel_filter = {
|
|
137
139
|
con_start_transport_op,
|
138
140
|
sizeof(call_data),
|
139
141
|
init_call_elem,
|
140
|
-
|
142
|
+
set_pollset_or_pollset_set,
|
141
143
|
destroy_call_elem,
|
142
144
|
sizeof(channel_data),
|
143
145
|
init_channel_elem,
|
@@ -38,6 +38,10 @@
|
|
38
38
|
#include "src/core/lib/profiling/timers.h"
|
39
39
|
#include "src/core/lib/support/string.h"
|
40
40
|
#include "src/core/lib/transport/static_metadata.h"
|
41
|
+
#include "src/core/lib/transport/transport_impl.h"
|
42
|
+
|
43
|
+
#define EXPECTED_CONTENT_TYPE "application/grpc"
|
44
|
+
#define EXPECTED_CONTENT_TYPE_LENGTH sizeof(EXPECTED_CONTENT_TYPE) - 1
|
41
45
|
|
42
46
|
typedef struct call_data {
|
43
47
|
grpc_linked_mdelem method;
|
@@ -74,13 +78,31 @@ static grpc_mdelem *client_recv_filter(void *user_data, grpc_mdelem *md) {
|
|
74
78
|
} else if (md->key == GRPC_MDSTR_STATUS) {
|
75
79
|
grpc_call_element_send_cancel(a->exec_ctx, a->elem);
|
76
80
|
return NULL;
|
81
|
+
} else if (md == GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC) {
|
82
|
+
return NULL;
|
77
83
|
} else if (md->key == GRPC_MDSTR_CONTENT_TYPE) {
|
84
|
+
const char *value_str = grpc_mdstr_as_c_string(md->value);
|
85
|
+
if (strncmp(value_str, EXPECTED_CONTENT_TYPE,
|
86
|
+
EXPECTED_CONTENT_TYPE_LENGTH) == 0 &&
|
87
|
+
(value_str[EXPECTED_CONTENT_TYPE_LENGTH] == '+' ||
|
88
|
+
value_str[EXPECTED_CONTENT_TYPE_LENGTH] == ';')) {
|
89
|
+
/* Although the C implementation doesn't (currently) generate them,
|
90
|
+
any custom +-suffix is explicitly valid. */
|
91
|
+
/* TODO(klempner): We should consider preallocating common values such
|
92
|
+
as +proto or +json, or at least stashing them if we see them. */
|
93
|
+
/* TODO(klempner): Should we be surfacing this to application code? */
|
94
|
+
} else {
|
95
|
+
/* TODO(klempner): We're currently allowing this, but we shouldn't
|
96
|
+
see it without a proxy so log for now. */
|
97
|
+
gpr_log(GPR_INFO, "Unexpected content-type '%s'", value_str);
|
98
|
+
}
|
78
99
|
return NULL;
|
79
100
|
}
|
80
101
|
return md;
|
81
102
|
}
|
82
103
|
|
83
|
-
static void hc_on_recv(grpc_exec_ctx *exec_ctx, void *user_data,
|
104
|
+
static void hc_on_recv(grpc_exec_ctx *exec_ctx, void *user_data,
|
105
|
+
grpc_error *error) {
|
84
106
|
grpc_call_element *elem = user_data;
|
85
107
|
call_data *calld = elem->call_data;
|
86
108
|
client_recv_filter_args a;
|
@@ -88,7 +110,7 @@ static void hc_on_recv(grpc_exec_ctx *exec_ctx, void *user_data, bool success) {
|
|
88
110
|
a.exec_ctx = exec_ctx;
|
89
111
|
grpc_metadata_batch_filter(calld->recv_initial_metadata, client_recv_filter,
|
90
112
|
&a);
|
91
|
-
calld->on_done_recv->cb(exec_ctx, calld->on_done_recv->cb_arg,
|
113
|
+
calld->on_done_recv->cb(exec_ctx, calld->on_done_recv->cb_arg, error);
|
92
114
|
}
|
93
115
|
|
94
116
|
static grpc_mdelem *client_strip_filter(void *user_data, grpc_mdelem *md) {
|
@@ -156,7 +178,7 @@ static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
|
156
178
|
|
157
179
|
/* Destructor for call_data */
|
158
180
|
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
159
|
-
void *ignored) {}
|
181
|
+
const grpc_call_stats *stats, void *ignored) {}
|
160
182
|
|
161
183
|
static grpc_mdelem *scheme_from_args(const grpc_channel_args *args) {
|
162
184
|
unsigned i;
|
@@ -179,7 +201,8 @@ static grpc_mdelem *scheme_from_args(const grpc_channel_args *args) {
|
|
179
201
|
return GRPC_MDELEM_SCHEME_HTTP;
|
180
202
|
}
|
181
203
|
|
182
|
-
static grpc_mdstr *user_agent_from_args(const grpc_channel_args *args
|
204
|
+
static grpc_mdstr *user_agent_from_args(const grpc_channel_args *args,
|
205
|
+
const char *transport_name) {
|
183
206
|
gpr_strvec v;
|
184
207
|
size_t i;
|
185
208
|
int is_first = 1;
|
@@ -201,8 +224,8 @@ static grpc_mdstr *user_agent_from_args(const grpc_channel_args *args) {
|
|
201
224
|
}
|
202
225
|
}
|
203
226
|
|
204
|
-
gpr_asprintf(&tmp, "%sgrpc-c/%s (%s)", is_first ? "" : " ",
|
205
|
-
grpc_version_string(), GPR_PLATFORM_STRING);
|
227
|
+
gpr_asprintf(&tmp, "%sgrpc-c/%s (%s; %s)", is_first ? "" : " ",
|
228
|
+
grpc_version_string(), GPR_PLATFORM_STRING, transport_name);
|
206
229
|
is_first = 0;
|
207
230
|
gpr_strvec_add(&v, tmp);
|
208
231
|
|
@@ -233,9 +256,12 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx,
|
|
233
256
|
grpc_channel_element_args *args) {
|
234
257
|
channel_data *chand = elem->channel_data;
|
235
258
|
GPR_ASSERT(!args->is_last);
|
259
|
+
GPR_ASSERT(args->optional_transport != NULL);
|
236
260
|
chand->static_scheme = scheme_from_args(args->channel_args);
|
237
261
|
chand->user_agent = grpc_mdelem_from_metadata_strings(
|
238
|
-
GRPC_MDSTR_USER_AGENT,
|
262
|
+
GRPC_MDSTR_USER_AGENT,
|
263
|
+
user_agent_from_args(args->channel_args,
|
264
|
+
args->optional_transport->vtable->name));
|
239
265
|
}
|
240
266
|
|
241
267
|
/* Destructor for channel data */
|
@@ -250,7 +276,7 @@ const grpc_channel_filter grpc_http_client_filter = {
|
|
250
276
|
grpc_channel_next_op,
|
251
277
|
sizeof(call_data),
|
252
278
|
init_call_elem,
|
253
|
-
|
279
|
+
grpc_call_stack_ignore_set_pollset_or_pollset_set,
|
254
280
|
destroy_call_elem,
|
255
281
|
sizeof(channel_data),
|
256
282
|
init_channel_elem,
|
@@ -1,5 +1,4 @@
|
|
1
1
|
/*
|
2
|
-
*
|
3
2
|
* Copyright 2015, Google Inc.
|
4
3
|
* All rights reserved.
|
5
4
|
*
|
@@ -39,6 +38,7 @@
|
|
39
38
|
/* Processes metadata on the client side for HTTP2 transports */
|
40
39
|
extern const grpc_channel_filter grpc_http_client_filter;
|
41
40
|
|
41
|
+
/* Channel arg to override the http2 :scheme header */
|
42
42
|
#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme"
|
43
43
|
|
44
44
|
#endif /* GRPC_CORE_LIB_CHANNEL_HTTP_CLIENT_FILTER_H */
|
@@ -108,7 +108,7 @@ static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) {
|
|
108
108
|
} else {
|
109
109
|
/* TODO(klempner): We're currently allowing this, but we shouldn't
|
110
110
|
see it without a proxy so log for now. */
|
111
|
-
gpr_log(GPR_INFO, "Unexpected content-type %s", value_str);
|
111
|
+
gpr_log(GPR_INFO, "Unexpected content-type '%s'", value_str);
|
112
112
|
}
|
113
113
|
return NULL;
|
114
114
|
} else if (md->key == GRPC_MDSTR_TE || md->key == GRPC_MDSTR_METHOD ||
|
@@ -142,10 +142,11 @@ static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) {
|
|
142
142
|
}
|
143
143
|
}
|
144
144
|
|
145
|
-
static void hs_on_recv(grpc_exec_ctx *exec_ctx, void *user_data,
|
145
|
+
static void hs_on_recv(grpc_exec_ctx *exec_ctx, void *user_data,
|
146
|
+
grpc_error *err) {
|
146
147
|
grpc_call_element *elem = user_data;
|
147
148
|
call_data *calld = elem->call_data;
|
148
|
-
if (
|
149
|
+
if (err == GRPC_ERROR_NONE) {
|
149
150
|
server_filter_args a;
|
150
151
|
a.elem = elem;
|
151
152
|
a.exec_ctx = exec_ctx;
|
@@ -157,27 +158,35 @@ static void hs_on_recv(grpc_exec_ctx *exec_ctx, void *user_data, bool success) {
|
|
157
158
|
calld->seen_path && calld->seen_authority) {
|
158
159
|
/* do nothing */
|
159
160
|
} else {
|
161
|
+
err = GRPC_ERROR_CREATE("Bad incoming HTTP headers");
|
160
162
|
if (!calld->seen_path) {
|
161
|
-
|
163
|
+
err = grpc_error_add_child(err,
|
164
|
+
GRPC_ERROR_CREATE("Missing :path header"));
|
162
165
|
}
|
163
166
|
if (!calld->seen_authority) {
|
164
|
-
|
167
|
+
err = grpc_error_add_child(
|
168
|
+
err, GRPC_ERROR_CREATE("Missing :authority header"));
|
165
169
|
}
|
166
170
|
if (!calld->seen_method) {
|
167
|
-
|
171
|
+
err = grpc_error_add_child(err,
|
172
|
+
GRPC_ERROR_CREATE("Missing :method header"));
|
168
173
|
}
|
169
174
|
if (!calld->seen_scheme) {
|
170
|
-
|
175
|
+
err = grpc_error_add_child(err,
|
176
|
+
GRPC_ERROR_CREATE("Missing :scheme header"));
|
171
177
|
}
|
172
178
|
if (!calld->seen_te_trailers) {
|
173
|
-
|
179
|
+
err = grpc_error_add_child(
|
180
|
+
err, GRPC_ERROR_CREATE("Missing te: trailers header"));
|
174
181
|
}
|
175
182
|
/* Error this call out */
|
176
|
-
success = 0;
|
177
183
|
grpc_call_element_send_cancel(exec_ctx, elem);
|
178
184
|
}
|
185
|
+
} else {
|
186
|
+
GRPC_ERROR_REF(err);
|
179
187
|
}
|
180
|
-
calld->on_done_recv->cb(exec_ctx, calld->on_done_recv->cb_arg,
|
188
|
+
calld->on_done_recv->cb(exec_ctx, calld->on_done_recv->cb_arg, err);
|
189
|
+
GRPC_ERROR_UNREF(err);
|
181
190
|
}
|
182
191
|
|
183
192
|
static void hs_mutate_op(grpc_call_element *elem,
|
@@ -226,7 +235,7 @@ static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
|
226
235
|
|
227
236
|
/* Destructor for call_data */
|
228
237
|
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
229
|
-
void *ignored) {}
|
238
|
+
const grpc_call_stats *stats, void *ignored) {}
|
230
239
|
|
231
240
|
/* Constructor for channel_data */
|
232
241
|
static void init_channel_elem(grpc_exec_ctx *exec_ctx,
|
@@ -244,7 +253,7 @@ const grpc_channel_filter grpc_http_server_filter = {
|
|
244
253
|
grpc_channel_next_op,
|
245
254
|
sizeof(call_data),
|
246
255
|
init_call_elem,
|
247
|
-
|
256
|
+
grpc_call_stack_ignore_set_pollset_or_pollset_set,
|
248
257
|
destroy_call_elem,
|
249
258
|
sizeof(channel_data),
|
250
259
|
init_channel_elem,
|
@@ -125,6 +125,28 @@ grpc_mdelem *grpc_compression_encoding_mdelem(
|
|
125
125
|
return NULL;
|
126
126
|
}
|
127
127
|
|
128
|
+
void grpc_compression_options_init(grpc_compression_options *opts) {
|
129
|
+
memset(opts, 0, sizeof(*opts));
|
130
|
+
/* all enabled by default */
|
131
|
+
opts->enabled_algorithms_bitset = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1;
|
132
|
+
}
|
133
|
+
|
134
|
+
void grpc_compression_options_enable_algorithm(
|
135
|
+
grpc_compression_options *opts, grpc_compression_algorithm algorithm) {
|
136
|
+
GPR_BITSET(&opts->enabled_algorithms_bitset, algorithm);
|
137
|
+
}
|
138
|
+
|
139
|
+
void grpc_compression_options_disable_algorithm(
|
140
|
+
grpc_compression_options *opts, grpc_compression_algorithm algorithm) {
|
141
|
+
GPR_BITCLEAR(&opts->enabled_algorithms_bitset, algorithm);
|
142
|
+
}
|
143
|
+
|
144
|
+
int grpc_compression_options_is_algorithm_enabled(
|
145
|
+
const grpc_compression_options *opts,
|
146
|
+
grpc_compression_algorithm algorithm) {
|
147
|
+
return GPR_BITGET(opts->enabled_algorithms_bitset, algorithm);
|
148
|
+
}
|
149
|
+
|
128
150
|
/* TODO(dgq): Add the ability to specify parameters to the individual
|
129
151
|
* compression algorithms */
|
130
152
|
grpc_compression_algorithm grpc_compression_algorithm_for_level(
|
@@ -180,24 +202,3 @@ grpc_compression_algorithm grpc_compression_algorithm_for_level(
|
|
180
202
|
abort();
|
181
203
|
};
|
182
204
|
}
|
183
|
-
|
184
|
-
void grpc_compression_options_init(grpc_compression_options *opts) {
|
185
|
-
opts->enabled_algorithms_bitset = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1;
|
186
|
-
opts->default_compression_algorithm = GRPC_COMPRESS_NONE;
|
187
|
-
}
|
188
|
-
|
189
|
-
void grpc_compression_options_enable_algorithm(
|
190
|
-
grpc_compression_options *opts, grpc_compression_algorithm algorithm) {
|
191
|
-
GPR_BITSET(&opts->enabled_algorithms_bitset, algorithm);
|
192
|
-
}
|
193
|
-
|
194
|
-
void grpc_compression_options_disable_algorithm(
|
195
|
-
grpc_compression_options *opts, grpc_compression_algorithm algorithm) {
|
196
|
-
GPR_BITCLEAR(&opts->enabled_algorithms_bitset, algorithm);
|
197
|
-
}
|
198
|
-
|
199
|
-
int grpc_compression_options_is_algorithm_enabled(
|
200
|
-
const grpc_compression_options *opts,
|
201
|
-
grpc_compression_algorithm algorithm) {
|
202
|
-
return GPR_BITGET(opts->enabled_algorithms_bitset, algorithm);
|
203
|
-
}
|
data/src/core/lib/http/httpcli.c
CHANGED
@@ -39,12 +39,14 @@
|
|
39
39
|
#include <grpc/support/alloc.h>
|
40
40
|
#include <grpc/support/log.h>
|
41
41
|
#include <grpc/support/string_util.h>
|
42
|
+
#include <grpc/support/useful.h>
|
42
43
|
|
43
44
|
#include "src/core/lib/http/format_request.h"
|
44
45
|
#include "src/core/lib/http/parser.h"
|
45
46
|
#include "src/core/lib/iomgr/endpoint.h"
|
46
47
|
#include "src/core/lib/iomgr/iomgr_internal.h"
|
47
48
|
#include "src/core/lib/iomgr/resolve_address.h"
|
49
|
+
#include "src/core/lib/iomgr/sockaddr_utils.h"
|
48
50
|
#include "src/core/lib/iomgr/tcp_client.h"
|
49
51
|
#include "src/core/lib/support/string.h"
|
50
52
|
|
@@ -59,16 +61,16 @@ typedef struct {
|
|
59
61
|
gpr_timespec deadline;
|
60
62
|
int have_read_byte;
|
61
63
|
const grpc_httpcli_handshaker *handshaker;
|
62
|
-
|
63
|
-
void *user_data;
|
64
|
+
grpc_closure *on_done;
|
64
65
|
grpc_httpcli_context *context;
|
65
|
-
|
66
|
+
grpc_polling_entity *pollent;
|
66
67
|
grpc_iomgr_object iomgr_obj;
|
67
68
|
gpr_slice_buffer incoming;
|
68
69
|
gpr_slice_buffer outgoing;
|
69
70
|
grpc_closure on_read;
|
70
71
|
grpc_closure done_write;
|
71
72
|
grpc_closure connected;
|
73
|
+
grpc_error *overall_error;
|
72
74
|
} internal_request;
|
73
75
|
|
74
76
|
static grpc_httpcli_get_override g_get_override = NULL;
|
@@ -76,6 +78,7 @@ static grpc_httpcli_post_override g_post_override = NULL;
|
|
76
78
|
|
77
79
|
static void plaintext_handshake(grpc_exec_ctx *exec_ctx, void *arg,
|
78
80
|
grpc_endpoint *endpoint, const char *host,
|
81
|
+
gpr_timespec deadline,
|
79
82
|
void (*on_done)(grpc_exec_ctx *exec_ctx,
|
80
83
|
void *arg,
|
81
84
|
grpc_endpoint *endpoint)) {
|
@@ -93,14 +96,14 @@ void grpc_httpcli_context_destroy(grpc_httpcli_context *context) {
|
|
93
96
|
grpc_pollset_set_destroy(context->pollset_set);
|
94
97
|
}
|
95
98
|
|
96
|
-
static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req
|
99
|
+
static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req,
|
100
|
+
grpc_error *due_to_error);
|
97
101
|
|
98
102
|
static void finish(grpc_exec_ctx *exec_ctx, internal_request *req,
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
success ? &req->parser.http.response : NULL);
|
103
|
+
grpc_error *error) {
|
104
|
+
grpc_polling_entity_del_from_pollset_set(exec_ctx, req->pollent,
|
105
|
+
req->context->pollset_set);
|
106
|
+
grpc_exec_ctx_sched(exec_ctx, req->on_done, error, NULL);
|
104
107
|
grpc_http_parser_destroy(&req->parser);
|
105
108
|
if (req->addresses != NULL) {
|
106
109
|
grpc_resolved_addresses_destroy(req->addresses);
|
@@ -114,39 +117,49 @@ static void finish(grpc_exec_ctx *exec_ctx, internal_request *req,
|
|
114
117
|
grpc_iomgr_unregister_object(&req->iomgr_obj);
|
115
118
|
gpr_slice_buffer_destroy(&req->incoming);
|
116
119
|
gpr_slice_buffer_destroy(&req->outgoing);
|
120
|
+
GRPC_ERROR_UNREF(req->overall_error);
|
117
121
|
gpr_free(req);
|
118
122
|
}
|
119
123
|
|
120
|
-
static void
|
124
|
+
static void append_error(internal_request *req, grpc_error *error) {
|
125
|
+
if (req->overall_error == GRPC_ERROR_NONE) {
|
126
|
+
req->overall_error = GRPC_ERROR_CREATE("Failed HTTP/1 client request");
|
127
|
+
}
|
128
|
+
grpc_resolved_address *addr = &req->addresses->addrs[req->next_address - 1];
|
129
|
+
char *addr_text = grpc_sockaddr_to_uri((struct sockaddr *)addr->addr);
|
130
|
+
req->overall_error = grpc_error_add_child(
|
131
|
+
req->overall_error,
|
132
|
+
grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS, addr_text));
|
133
|
+
gpr_free(addr_text);
|
134
|
+
}
|
121
135
|
|
122
136
|
static void do_read(grpc_exec_ctx *exec_ctx, internal_request *req) {
|
123
137
|
grpc_endpoint_read(exec_ctx, req->ep, &req->incoming, &req->on_read);
|
124
138
|
}
|
125
139
|
|
126
|
-
static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
|
140
|
+
static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
|
141
|
+
grpc_error *error) {
|
127
142
|
internal_request *req = user_data;
|
128
143
|
size_t i;
|
129
144
|
|
130
145
|
for (i = 0; i < req->incoming.count; i++) {
|
131
146
|
if (GPR_SLICE_LENGTH(req->incoming.slices[i])) {
|
132
147
|
req->have_read_byte = 1;
|
133
|
-
|
134
|
-
|
148
|
+
grpc_error *err =
|
149
|
+
grpc_http_parser_parse(&req->parser, req->incoming.slices[i]);
|
150
|
+
if (err != GRPC_ERROR_NONE) {
|
151
|
+
finish(exec_ctx, req, err);
|
135
152
|
return;
|
136
153
|
}
|
137
154
|
}
|
138
155
|
}
|
139
156
|
|
140
|
-
if (
|
157
|
+
if (error == GRPC_ERROR_NONE) {
|
141
158
|
do_read(exec_ctx, req);
|
142
159
|
} else if (!req->have_read_byte) {
|
143
|
-
next_address(exec_ctx, req);
|
160
|
+
next_address(exec_ctx, req, GRPC_ERROR_REF(error));
|
144
161
|
} else {
|
145
|
-
|
146
|
-
if (parse_success && (req->parser.type != GRPC_HTTP_RESPONSE)) {
|
147
|
-
parse_success = 0;
|
148
|
-
}
|
149
|
-
finish(exec_ctx, req, parse_success);
|
162
|
+
finish(exec_ctx, req, grpc_http_parser_eof(&req->parser));
|
150
163
|
}
|
151
164
|
}
|
152
165
|
|
@@ -154,12 +167,12 @@ static void on_written(grpc_exec_ctx *exec_ctx, internal_request *req) {
|
|
154
167
|
do_read(exec_ctx, req);
|
155
168
|
}
|
156
169
|
|
157
|
-
static void done_write(grpc_exec_ctx *exec_ctx, void *arg,
|
170
|
+
static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
|
158
171
|
internal_request *req = arg;
|
159
|
-
if (
|
172
|
+
if (error == GRPC_ERROR_NONE) {
|
160
173
|
on_written(exec_ctx, req);
|
161
174
|
} else {
|
162
|
-
next_address(exec_ctx, req);
|
175
|
+
next_address(exec_ctx, req, GRPC_ERROR_REF(error));
|
163
176
|
}
|
164
177
|
}
|
165
178
|
|
@@ -174,7 +187,8 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
|
|
174
187
|
internal_request *req = arg;
|
175
188
|
|
176
189
|
if (!ep) {
|
177
|
-
next_address(exec_ctx, req
|
190
|
+
next_address(exec_ctx, req,
|
191
|
+
GRPC_ERROR_CREATE("Unexplained handshake failure"));
|
178
192
|
return;
|
179
193
|
}
|
180
194
|
|
@@ -182,23 +196,30 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
|
|
182
196
|
start_write(exec_ctx, req);
|
183
197
|
}
|
184
198
|
|
185
|
-
static void on_connected(grpc_exec_ctx *exec_ctx, void *arg,
|
199
|
+
static void on_connected(grpc_exec_ctx *exec_ctx, void *arg,
|
200
|
+
grpc_error *error) {
|
186
201
|
internal_request *req = arg;
|
187
202
|
|
188
203
|
if (!req->ep) {
|
189
|
-
next_address(exec_ctx, req);
|
204
|
+
next_address(exec_ctx, req, GRPC_ERROR_REF(error));
|
190
205
|
return;
|
191
206
|
}
|
192
207
|
req->handshaker->handshake(
|
193
208
|
exec_ctx, req, req->ep,
|
194
209
|
req->ssl_host_override ? req->ssl_host_override : req->host,
|
195
|
-
on_handshake_done);
|
210
|
+
req->deadline, on_handshake_done);
|
196
211
|
}
|
197
212
|
|
198
|
-
static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req
|
213
|
+
static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req,
|
214
|
+
grpc_error *error) {
|
199
215
|
grpc_resolved_address *addr;
|
216
|
+
if (error != GRPC_ERROR_NONE) {
|
217
|
+
append_error(req, error);
|
218
|
+
}
|
200
219
|
if (req->next_address == req->addresses->naddrs) {
|
201
|
-
finish(exec_ctx, req,
|
220
|
+
finish(exec_ctx, req,
|
221
|
+
GRPC_ERROR_CREATE_REFERENCING("Failed HTTP requests to all targets",
|
222
|
+
&req->overall_error, 1));
|
202
223
|
return;
|
203
224
|
}
|
204
225
|
addr = &req->addresses->addrs[req->next_address++];
|
@@ -208,34 +229,34 @@ static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req) {
|
|
208
229
|
(struct sockaddr *)&addr->addr, addr->len, req->deadline);
|
209
230
|
}
|
210
231
|
|
211
|
-
static void on_resolved(grpc_exec_ctx *exec_ctx, void *arg,
|
212
|
-
grpc_resolved_addresses *addresses) {
|
232
|
+
static void on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
|
213
233
|
internal_request *req = arg;
|
214
|
-
if (
|
215
|
-
finish(exec_ctx, req,
|
234
|
+
if (error != GRPC_ERROR_NONE) {
|
235
|
+
finish(exec_ctx, req, error);
|
216
236
|
return;
|
217
237
|
}
|
218
|
-
req->addresses = addresses;
|
219
238
|
req->next_address = 0;
|
220
|
-
next_address(exec_ctx, req);
|
239
|
+
next_address(exec_ctx, req, GRPC_ERROR_NONE);
|
221
240
|
}
|
222
241
|
|
223
|
-
static void internal_request_begin(
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
242
|
+
static void internal_request_begin(grpc_exec_ctx *exec_ctx,
|
243
|
+
grpc_httpcli_context *context,
|
244
|
+
grpc_polling_entity *pollent,
|
245
|
+
const grpc_httpcli_request *request,
|
246
|
+
gpr_timespec deadline, grpc_closure *on_done,
|
247
|
+
grpc_httpcli_response *response,
|
248
|
+
const char *name, gpr_slice request_text) {
|
228
249
|
internal_request *req = gpr_malloc(sizeof(internal_request));
|
229
250
|
memset(req, 0, sizeof(*req));
|
230
251
|
req->request_text = request_text;
|
231
|
-
grpc_http_parser_init(&req->parser);
|
232
|
-
req->
|
233
|
-
req->user_data = user_data;
|
252
|
+
grpc_http_parser_init(&req->parser, GRPC_HTTP_RESPONSE, response);
|
253
|
+
req->on_done = on_done;
|
234
254
|
req->deadline = deadline;
|
235
255
|
req->handshaker =
|
236
256
|
request->handshaker ? request->handshaker : &grpc_httpcli_plaintext;
|
237
257
|
req->context = context;
|
238
|
-
req->
|
258
|
+
req->pollent = pollent;
|
259
|
+
req->overall_error = GRPC_ERROR_NONE;
|
239
260
|
grpc_closure_init(&req->on_read, on_read, req);
|
240
261
|
grpc_closure_init(&req->done_write, done_write, req);
|
241
262
|
gpr_slice_buffer_init(&req->incoming);
|
@@ -244,45 +265,46 @@ static void internal_request_begin(
|
|
244
265
|
req->host = gpr_strdup(request->host);
|
245
266
|
req->ssl_host_override = gpr_strdup(request->ssl_host_override);
|
246
267
|
|
247
|
-
|
248
|
-
|
268
|
+
GPR_ASSERT(pollent);
|
269
|
+
grpc_polling_entity_add_to_pollset_set(exec_ctx, req->pollent,
|
270
|
+
req->context->pollset_set);
|
249
271
|
grpc_resolve_address(exec_ctx, request->host, req->handshaker->default_port,
|
250
|
-
on_resolved, req);
|
272
|
+
grpc_closure_create(on_resolved, req), &req->addresses);
|
251
273
|
}
|
252
274
|
|
253
275
|
void grpc_httpcli_get(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
|
254
|
-
|
276
|
+
grpc_polling_entity *pollent,
|
255
277
|
const grpc_httpcli_request *request,
|
256
|
-
gpr_timespec deadline,
|
257
|
-
|
278
|
+
gpr_timespec deadline, grpc_closure *on_done,
|
279
|
+
grpc_httpcli_response *response) {
|
258
280
|
char *name;
|
259
281
|
if (g_get_override &&
|
260
|
-
g_get_override(exec_ctx, request, deadline,
|
282
|
+
g_get_override(exec_ctx, request, deadline, on_done, response)) {
|
261
283
|
return;
|
262
284
|
}
|
263
285
|
gpr_asprintf(&name, "HTTP:GET:%s:%s", request->host, request->http.path);
|
264
|
-
internal_request_begin(exec_ctx, context,
|
265
|
-
|
286
|
+
internal_request_begin(exec_ctx, context, pollent, request, deadline, on_done,
|
287
|
+
response, name,
|
266
288
|
grpc_httpcli_format_get_request(request));
|
267
289
|
gpr_free(name);
|
268
290
|
}
|
269
291
|
|
270
292
|
void grpc_httpcli_post(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
|
271
|
-
|
293
|
+
grpc_polling_entity *pollent,
|
272
294
|
const grpc_httpcli_request *request,
|
273
295
|
const char *body_bytes, size_t body_size,
|
274
|
-
gpr_timespec deadline,
|
275
|
-
|
296
|
+
gpr_timespec deadline, grpc_closure *on_done,
|
297
|
+
grpc_httpcli_response *response) {
|
276
298
|
char *name;
|
277
299
|
if (g_post_override &&
|
278
300
|
g_post_override(exec_ctx, request, body_bytes, body_size, deadline,
|
279
|
-
|
301
|
+
on_done, response)) {
|
280
302
|
return;
|
281
303
|
}
|
282
304
|
gpr_asprintf(&name, "HTTP:POST:%s:%s", request->host, request->http.path);
|
283
305
|
internal_request_begin(
|
284
|
-
exec_ctx, context,
|
285
|
-
|
306
|
+
exec_ctx, context, pollent, request, deadline, on_done, response, name,
|
307
|
+
grpc_httpcli_format_post_request(request, body_bytes, body_size));
|
286
308
|
gpr_free(name);
|
287
309
|
}
|
288
310
|
|