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.

Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1398 -817
  3. data/include/grpc/compression.h +2 -1
  4. data/include/grpc/grpc.h +10 -1
  5. data/include/grpc/grpc_cronet.h +51 -0
  6. data/include/grpc/grpc_posix.h +70 -0
  7. data/include/grpc/impl/codegen/atm.h +2 -2
  8. data/include/grpc/impl/codegen/{atm_win32.h → atm_windows.h} +3 -3
  9. data/include/grpc/impl/codegen/compression_types.h +39 -5
  10. data/include/grpc/impl/codegen/connectivity_state.h +1 -1
  11. data/include/grpc/impl/codegen/grpc_types.h +10 -0
  12. data/include/grpc/impl/codegen/log.h +2 -1
  13. data/include/grpc/impl/codegen/port_platform.h +30 -12
  14. data/include/grpc/impl/codegen/slice_buffer.h +2 -3
  15. data/include/grpc/impl/codegen/sync.h +2 -2
  16. data/include/grpc/impl/codegen/{sync_win32.h → sync_windows.h} +3 -3
  17. data/include/grpc/support/{sync_win32.h → atm_windows.h} +4 -4
  18. data/include/grpc/support/avl.h +5 -0
  19. data/include/grpc/support/{log_win32.h → log_windows.h} +3 -3
  20. data/include/grpc/support/string_util.h +2 -1
  21. data/include/grpc/support/{atm_win32.h → sync_windows.h} +4 -4
  22. data/src/core/ext/census/gen/census.pb.c +179 -0
  23. data/src/core/ext/census/gen/census.pb.h +294 -0
  24. data/src/core/ext/census/grpc_filter.c +11 -7
  25. data/src/core/ext/client_config/channel_connectivity.c +28 -14
  26. data/src/core/ext/client_config/client_channel.c +77 -53
  27. data/src/core/ext/client_config/connector.h +1 -1
  28. data/src/core/ext/client_config/lb_policy.c +9 -6
  29. data/src/core/ext/client_config/lb_policy.h +9 -5
  30. data/src/core/ext/client_config/subchannel.c +58 -39
  31. data/src/core/ext/client_config/subchannel.h +3 -2
  32. data/src/core/ext/client_config/subchannel_call_holder.c +34 -19
  33. data/src/core/ext/client_config/subchannel_call_holder.h +2 -1
  34. data/src/core/ext/client_config/subchannel_index.c +20 -9
  35. data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +7 -7
  36. data/src/core/ext/lb_policy/grpclb/load_balancer_api.h +5 -5
  37. data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/{v0 → v1}/load_balancer.pb.c +29 -30
  38. data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +178 -0
  39. data/src/core/ext/lb_policy/pick_first/pick_first.c +65 -45
  40. data/src/core/ext/lb_policy/round_robin/round_robin.c +84 -43
  41. data/src/core/ext/load_reporting/load_reporting.c +133 -0
  42. data/src/core/ext/load_reporting/load_reporting.h +75 -0
  43. data/src/core/ext/load_reporting/load_reporting_filter.c +151 -0
  44. data/src/core/ext/load_reporting/load_reporting_filter.h +41 -0
  45. data/src/core/ext/resolver/dns/native/dns_resolver.c +22 -8
  46. data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +2 -2
  47. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +4 -4
  48. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +95 -0
  49. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +14 -18
  50. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +49 -24
  51. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +82 -0
  52. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +104 -60
  53. data/src/core/ext/transport/chttp2/transport/bin_decoder.c +232 -0
  54. data/src/{ruby/ext/grpc/rb_signal.c → core/ext/transport/chttp2/transport/bin_decoder.h} +27 -31
  55. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +481 -260
  56. data/src/core/ext/transport/chttp2/transport/frame.h +1 -7
  57. data/src/core/ext/transport/chttp2/transport/frame_data.c +44 -27
  58. data/src/core/ext/transport/chttp2/transport/frame_data.h +6 -5
  59. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +23 -17
  60. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -2
  61. data/src/core/ext/transport/chttp2/transport/frame_ping.c +12 -7
  62. data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -3
  63. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +25 -12
  64. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -2
  65. data/src/core/ext/transport/chttp2/transport/frame_settings.c +23 -21
  66. data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -2
  67. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -9
  68. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -2
  69. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +365 -287
  70. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +8 -6
  71. data/src/core/ext/transport/chttp2/transport/hpack_table.c +24 -20
  72. data/src/core/ext/transport/chttp2/transport/hpack_table.h +5 -4
  73. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +1 -0
  74. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +1 -0
  75. data/src/core/ext/transport/chttp2/transport/internal.h +34 -32
  76. data/src/core/ext/transport/chttp2/transport/parsing.c +296 -212
  77. data/src/core/ext/transport/chttp2/transport/writing.c +12 -9
  78. data/src/core/lib/channel/channel_args.c +26 -12
  79. data/src/core/lib/channel/channel_args.h +1 -1
  80. data/src/core/lib/channel/channel_stack.c +12 -8
  81. data/src/core/lib/channel/channel_stack.h +27 -11
  82. data/src/core/lib/channel/channel_stack_builder.c +2 -2
  83. data/src/core/lib/channel/compress_filter.c +26 -31
  84. data/src/core/lib/channel/compress_filter.h +4 -4
  85. data/src/core/lib/channel/connected_channel.c +7 -5
  86. data/src/core/lib/channel/http_client_filter.c +34 -8
  87. data/src/core/lib/channel/http_client_filter.h +1 -1
  88. data/src/core/lib/channel/http_server_filter.c +21 -12
  89. data/src/core/lib/compression/{compression_algorithm.c → compression.c} +22 -21
  90. data/src/core/lib/http/httpcli.c +81 -59
  91. data/src/core/lib/http/httpcli.h +11 -15
  92. data/src/core/lib/http/httpcli_security_connector.c +5 -3
  93. data/src/core/lib/http/parser.c +127 -118
  94. data/src/core/lib/http/parser.h +11 -6
  95. data/src/core/lib/iomgr/closure.c +20 -16
  96. data/src/core/lib/iomgr/closure.h +19 -15
  97. data/src/core/lib/iomgr/endpoint.h +1 -1
  98. data/src/core/lib/iomgr/endpoint_pair_posix.c +2 -2
  99. data/src/core/lib/iomgr/error.c +535 -0
  100. data/src/core/lib/iomgr/error.h +192 -0
  101. data/src/core/lib/iomgr/ev_poll_and_epoll_posix.c +190 -83
  102. data/src/core/lib/iomgr/ev_poll_posix.c +1267 -0
  103. data/src/{ruby/ext/grpc/rb_signal.h → core/lib/iomgr/ev_poll_posix.h} +7 -5
  104. data/src/core/lib/iomgr/ev_posix.c +104 -14
  105. data/src/core/lib/iomgr/ev_posix.h +17 -7
  106. data/src/core/lib/iomgr/exec_ctx.c +25 -7
  107. data/src/core/lib/iomgr/exec_ctx.h +27 -8
  108. data/src/core/lib/iomgr/executor.c +2 -2
  109. data/src/core/lib/iomgr/executor.h +1 -1
  110. data/src/core/lib/iomgr/iocp_windows.c +2 -41
  111. data/src/core/lib/iomgr/iocp_windows.h +0 -8
  112. data/src/core/lib/iomgr/iomgr.c +5 -4
  113. data/src/core/lib/iomgr/iomgr_posix.c +5 -1
  114. data/src/core/lib/iomgr/iomgr_windows.c +1 -1
  115. data/src/core/lib/{support → iomgr}/load_file.c +15 -17
  116. data/src/core/lib/{support → iomgr}/load_file.h +8 -7
  117. data/src/core/lib/iomgr/polling_entity.c +104 -0
  118. data/src/core/lib/iomgr/polling_entity.h +81 -0
  119. data/src/core/lib/iomgr/pollset.h +6 -5
  120. data/src/core/lib/iomgr/pollset_set_windows.c +4 -1
  121. data/src/core/lib/iomgr/pollset_windows.c +10 -6
  122. data/src/core/lib/iomgr/resolve_address.h +5 -9
  123. data/src/core/lib/iomgr/resolve_address_posix.c +55 -38
  124. data/src/core/lib/iomgr/resolve_address_windows.c +51 -37
  125. data/src/core/lib/iomgr/sockaddr.h +2 -2
  126. data/src/core/lib/iomgr/{sockaddr_win32.h → sockaddr_windows.h} +3 -3
  127. data/src/core/lib/iomgr/socket_utils_common_posix.c +92 -45
  128. data/src/core/lib/iomgr/socket_utils_posix.h +19 -12
  129. data/src/core/lib/iomgr/socket_windows.c +61 -2
  130. data/src/core/lib/iomgr/socket_windows.h +13 -0
  131. data/src/core/lib/iomgr/tcp_client_posix.c +54 -39
  132. data/src/core/lib/iomgr/tcp_client_windows.c +34 -34
  133. data/src/core/lib/iomgr/tcp_posix.c +43 -39
  134. data/src/core/lib/iomgr/tcp_server.h +5 -3
  135. data/src/core/lib/iomgr/tcp_server_posix.c +103 -64
  136. data/src/core/lib/iomgr/tcp_server_windows.c +114 -101
  137. data/src/core/lib/iomgr/tcp_windows.c +45 -50
  138. data/src/core/lib/iomgr/tcp_windows.h +1 -1
  139. data/src/core/lib/iomgr/timer.c +26 -13
  140. data/src/core/lib/iomgr/udp_server.c +28 -4
  141. data/src/core/lib/iomgr/udp_server.h +5 -1
  142. data/src/core/lib/iomgr/unix_sockets_posix.c +8 -7
  143. data/src/core/lib/iomgr/unix_sockets_posix.h +2 -1
  144. data/src/core/lib/iomgr/unix_sockets_posix_noop.c +4 -2
  145. data/src/core/lib/iomgr/wakeup_fd_eventfd.c +15 -5
  146. data/src/core/lib/iomgr/wakeup_fd_pipe.c +13 -9
  147. data/src/core/lib/iomgr/wakeup_fd_posix.c +6 -6
  148. data/src/core/lib/iomgr/wakeup_fd_posix.h +9 -6
  149. data/src/core/lib/iomgr/workqueue.h +5 -4
  150. data/src/core/lib/iomgr/workqueue_posix.c +40 -26
  151. data/src/core/lib/iomgr/workqueue_windows.c +2 -2
  152. data/src/core/lib/profiling/basic_timers.c +2 -2
  153. data/src/core/lib/security/{security_context.c → context/security_context.c} +1 -1
  154. data/src/core/lib/security/{security_context.h → context/security_context.h} +4 -4
  155. data/src/core/lib/security/credentials/composite/composite_credentials.c +263 -0
  156. data/src/core/lib/security/credentials/composite/composite_credentials.h +72 -0
  157. data/src/core/lib/security/credentials/credentials.c +233 -0
  158. data/src/core/lib/security/{credentials.h → credentials/credentials.h} +19 -157
  159. data/src/core/lib/security/{credentials_metadata.c → credentials/credentials_metadata.c} +1 -1
  160. data/src/core/lib/security/credentials/fake/fake_credentials.c +139 -0
  161. data/src/core/lib/security/credentials/fake/fake_credentials.h +56 -0
  162. data/src/core/lib/security/{credentials_posix.c → credentials/google_default/credentials_posix.c} +1 -1
  163. data/src/core/lib/security/{credentials_win32.c → credentials/google_default/credentials_windows.c} +3 -3
  164. data/src/core/lib/security/{google_default_credentials.c → credentials/google_default/google_default_credentials.c} +93 -35
  165. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +46 -0
  166. data/src/core/lib/security/credentials/iam/iam_credentials.c +85 -0
  167. data/src/core/lib/security/credentials/iam/iam_credentials.h +44 -0
  168. data/src/core/lib/security/{json_token.c → credentials/jwt/json_token.c} +10 -101
  169. data/src/core/lib/security/{json_token.h → credentials/jwt/json_token.h} +3 -33
  170. data/src/core/lib/security/credentials/jwt/jwt_credentials.c +160 -0
  171. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +62 -0
  172. data/src/core/lib/security/{jwt_verifier.c → credentials/jwt/jwt_verifier.c} +35 -15
  173. data/src/core/lib/security/{jwt_verifier.h → credentials/jwt/jwt_verifier.h} +3 -3
  174. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +433 -0
  175. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +109 -0
  176. data/src/core/lib/security/credentials/plugin/plugin_credentials.c +129 -0
  177. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +45 -0
  178. data/src/core/lib/security/credentials/ssl/ssl_credentials.c +240 -0
  179. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +48 -0
  180. data/src/core/lib/security/{auth_filters.h → transport/auth_filters.h} +3 -3
  181. data/src/core/lib/security/{client_auth_filter.c → transport/client_auth_filter.c} +27 -20
  182. data/src/core/lib/security/{handshake.c → transport/handshake.c} +77 -45
  183. data/src/core/lib/security/{handshake.h → transport/handshake.h} +9 -11
  184. data/src/core/lib/security/{secure_endpoint.c → transport/secure_endpoint.c} +19 -12
  185. data/src/core/lib/security/{secure_endpoint.h → transport/secure_endpoint.h} +3 -3
  186. data/src/core/lib/security/{security_connector.c → transport/security_connector.c} +26 -17
  187. data/src/core/lib/security/{security_connector.h → transport/security_connector.h} +8 -8
  188. data/src/core/lib/security/{server_auth_filter.c → transport/server_auth_filter.c} +24 -16
  189. data/src/core/lib/security/transport/tsi_error.c +40 -0
  190. data/src/core/lib/security/transport/tsi_error.h +42 -0
  191. data/src/core/lib/security/{b64.c → util/b64.c} +1 -1
  192. data/src/core/lib/security/{b64.h → util/b64.h} +3 -3
  193. data/src/core/lib/security/util/json_util.c +61 -0
  194. data/src/core/lib/security/util/json_util.h +55 -0
  195. data/src/core/lib/support/avl.c +11 -0
  196. data/src/core/lib/support/cpu_windows.c +2 -2
  197. data/src/core/lib/support/{env_win32.c → env_windows.c} +3 -3
  198. data/src/core/lib/support/log.c +3 -1
  199. data/src/core/lib/support/log_linux.c +2 -2
  200. data/src/core/lib/support/{log_win32.c → log_windows.c} +4 -4
  201. data/src/core/lib/support/murmur_hash.c +3 -5
  202. data/src/core/lib/support/string.c +10 -0
  203. data/src/core/lib/support/string.h +4 -0
  204. data/src/core/lib/support/{string_util_win32.c → string_util_windows.c} +3 -3
  205. data/src/core/lib/support/{string_win32.c → string_windows.c} +2 -2
  206. data/src/core/lib/support/{string_win32.h → string_windows.h} +5 -5
  207. data/src/core/lib/support/subprocess_windows.c +1 -1
  208. data/src/core/lib/support/{sync_win32.c → sync_windows.c} +2 -2
  209. data/src/core/lib/support/{thd_win32.c → thd_windows.c} +2 -2
  210. data/src/core/lib/support/{time_win32.c → time_windows.c} +2 -2
  211. data/src/core/lib/support/tmpfile_msys.c +1 -1
  212. data/src/core/lib/support/{tmpfile_win32.c → tmpfile_windows.c} +3 -3
  213. data/src/core/lib/surface/alarm.c +2 -2
  214. data/src/core/lib/surface/byte_buffer_reader.c +13 -6
  215. data/src/core/lib/surface/call.c +323 -123
  216. data/src/core/lib/surface/call.h +2 -0
  217. data/src/core/lib/surface/call_log_batch.c +1 -1
  218. data/src/core/lib/surface/channel.c +64 -15
  219. data/src/core/lib/surface/channel.h +9 -0
  220. data/src/core/lib/surface/channel_ping.c +3 -3
  221. data/src/core/lib/surface/completion_queue.c +75 -19
  222. data/src/core/lib/surface/completion_queue.h +7 -2
  223. data/src/core/lib/surface/init.c +2 -1
  224. data/src/core/lib/surface/init_secure.c +4 -4
  225. data/src/core/lib/surface/lame_client.c +12 -8
  226. data/src/core/lib/surface/server.c +213 -120
  227. data/src/core/lib/surface/server.h +1 -0
  228. data/src/core/lib/surface/version.c +1 -1
  229. data/src/core/lib/transport/connectivity_state.c +40 -18
  230. data/src/core/lib/transport/connectivity_state.h +4 -1
  231. data/src/core/lib/transport/metadata.c +23 -23
  232. data/src/core/lib/transport/metadata.h +4 -0
  233. data/src/core/lib/transport/metadata_batch.c +9 -0
  234. data/src/core/lib/transport/metadata_batch.h +3 -0
  235. data/src/core/lib/transport/static_metadata.c +6 -5
  236. data/src/core/lib/transport/static_metadata.h +64 -60
  237. data/src/core/lib/transport/transport.c +24 -12
  238. data/src/core/lib/transport/transport.h +6 -5
  239. data/src/core/lib/transport/transport_impl.h +4 -0
  240. data/src/core/lib/transport/transport_op_string.c +2 -2
  241. data/src/core/plugin_registry/grpc_plugin_registry.c +4 -0
  242. data/src/ruby/bin/math_services.rb +41 -2
  243. data/src/ruby/ext/grpc/rb_call.c +42 -40
  244. data/src/ruby/ext/grpc/rb_channel.c +1 -1
  245. data/src/ruby/ext/grpc/rb_completion_queue.c +59 -6
  246. data/src/ruby/ext/grpc/rb_completion_queue.h +1 -1
  247. data/src/ruby/ext/grpc/rb_grpc.c +1 -3
  248. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -2
  249. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +21 -5
  250. data/src/ruby/ext/grpc/rb_loader.c +1 -1
  251. data/src/ruby/ext/grpc/rb_server.c +5 -3
  252. data/src/ruby/lib/grpc.rb +0 -3
  253. data/src/ruby/lib/grpc/errors.rb +3 -2
  254. data/src/ruby/lib/grpc/generic/active_call.rb +32 -42
  255. data/src/ruby/lib/grpc/generic/bidi_call.rb +20 -0
  256. data/src/ruby/lib/grpc/generic/client_stub.rb +31 -54
  257. data/src/ruby/lib/grpc/generic/rpc_desc.rb +4 -4
  258. data/src/ruby/lib/grpc/generic/rpc_server.rb +12 -23
  259. data/src/ruby/lib/grpc/generic/service.rb +8 -8
  260. data/src/ruby/lib/grpc/version.rb +1 -1
  261. data/src/ruby/pb/grpc/health/v1/health_services.rb +30 -2
  262. data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb +34 -4
  263. data/src/ruby/pb/grpc/testing/metrics_services.rb +39 -2
  264. data/src/ruby/pb/src/proto/grpc/testing/empty.rb +15 -0
  265. data/src/ruby/pb/src/proto/grpc/testing/messages.rb +84 -0
  266. data/src/ruby/pb/src/proto/grpc/testing/test.rb +14 -0
  267. data/src/ruby/pb/src/proto/grpc/testing/test_services.rb +110 -0
  268. data/src/ruby/pb/test/client.rb +5 -2
  269. data/src/ruby/spec/generic/active_call_spec.rb +3 -2
  270. data/src/ruby/spec/generic/client_stub_spec.rb +27 -24
  271. data/src/ruby/spec/generic/rpc_desc_spec.rb +11 -11
  272. data/src/ruby/spec/generic/rpc_server_spec.rb +42 -61
  273. data/src/ruby/spec/pb/health/checker_spec.rb +3 -5
  274. metadata +86 -48
  275. data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h +0 -182
  276. data/src/core/lib/security/credentials.c +0 -1296
  277. 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 "src/core/lib/channel/channel_stack.h"
37
+ #include <grpc/impl/codegen/compression_types.h>
38
38
 
39
- #define GRPC_COMPRESS_REQUEST_ALGORITHM_KEY "grpc-internal-encoding-request"
39
+ #include "src/core/lib/channel/channel_stack.h"
40
40
 
41
- extern int grpc_compress_filter_trace;
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 GRPC_COMPRESS_REQUEST_ALGORITHM_KEY.
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 set_pollset(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
97
- grpc_pollset *pollset) {
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
- grpc_transport_set_pollset(exec_ctx, chand->transport,
101
- TRANSPORT_STREAM_FROM_CALL_DATA(calld), pollset);
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
- set_pollset,
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, bool success) {
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, success);
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, user_agent_from_args(args->channel_args));
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
- grpc_call_stack_ignore_set_pollset,
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, bool success) {
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 (success) {
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
- gpr_log(GPR_ERROR, "Missing :path header");
163
+ err = grpc_error_add_child(err,
164
+ GRPC_ERROR_CREATE("Missing :path header"));
162
165
  }
163
166
  if (!calld->seen_authority) {
164
- gpr_log(GPR_ERROR, "Missing :authority header");
167
+ err = grpc_error_add_child(
168
+ err, GRPC_ERROR_CREATE("Missing :authority header"));
165
169
  }
166
170
  if (!calld->seen_method) {
167
- gpr_log(GPR_ERROR, "Missing :method header");
171
+ err = grpc_error_add_child(err,
172
+ GRPC_ERROR_CREATE("Missing :method header"));
168
173
  }
169
174
  if (!calld->seen_scheme) {
170
- gpr_log(GPR_ERROR, "Missing :scheme header");
175
+ err = grpc_error_add_child(err,
176
+ GRPC_ERROR_CREATE("Missing :scheme header"));
171
177
  }
172
178
  if (!calld->seen_te_trailers) {
173
- gpr_log(GPR_ERROR, "Missing te trailers header");
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, success);
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
- grpc_call_stack_ignore_set_pollset,
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
- }
@@ -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
- grpc_httpcli_response_cb on_response;
63
- void *user_data;
64
+ grpc_closure *on_done;
64
65
  grpc_httpcli_context *context;
65
- grpc_pollset *pollset;
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
- int success) {
100
- grpc_pollset_set_del_pollset(exec_ctx, req->context->pollset_set,
101
- req->pollset);
102
- req->on_response(exec_ctx, req->user_data,
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 on_read(grpc_exec_ctx *exec_ctx, void *user_data, bool success);
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, bool success) {
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
- if (!grpc_http_parser_parse(&req->parser, req->incoming.slices[i])) {
134
- finish(exec_ctx, req, 0);
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 (success) {
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
- int parse_success = grpc_http_parser_eof(&req->parser);
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, bool success) {
170
+ static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
158
171
  internal_request *req = arg;
159
- if (success) {
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, bool success) {
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, 0);
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 (!addresses) {
215
- finish(exec_ctx, req, 0);
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
- grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
225
- grpc_pollset *pollset, const grpc_httpcli_request *request,
226
- gpr_timespec deadline, grpc_httpcli_response_cb on_response,
227
- void *user_data, const char *name, gpr_slice request_text) {
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->on_response = on_response;
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->pollset = pollset;
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
- grpc_pollset_set_add_pollset(exec_ctx, req->context->pollset_set,
248
- req->pollset);
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
- grpc_pollset *pollset,
276
+ grpc_polling_entity *pollent,
255
277
  const grpc_httpcli_request *request,
256
- gpr_timespec deadline,
257
- grpc_httpcli_response_cb on_response, void *user_data) {
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, on_response, user_data)) {
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, pollset, request, deadline,
265
- on_response, user_data, name,
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
- grpc_pollset *pollset,
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
- grpc_httpcli_response_cb on_response, void *user_data) {
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
- on_response, user_data)) {
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, pollset, request, deadline, on_response, user_data,
285
- name, grpc_httpcli_format_post_request(request, body_bytes, body_size));
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