puma-plus-core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1055) hide show
  1. checksums.yaml +7 -0
  2. data/ext/puma_plus_core/extconf.rb +85 -0
  3. data/go/cmd/puma-plus/main.go +472 -0
  4. data/go/go.mod +20 -0
  5. data/go/go.sum +38 -0
  6. data/go/internal/control/booted_test.go +97 -0
  7. data/go/internal/control/decide.go +427 -0
  8. data/go/internal/control/decide_test.go +526 -0
  9. data/go/internal/control/loop.go +343 -0
  10. data/go/internal/control/loop_test.go +228 -0
  11. data/go/internal/control/replay.go +121 -0
  12. data/go/internal/control/sim/cooldown_test.go +74 -0
  13. data/go/internal/control/sim/sim.go +599 -0
  14. data/go/internal/control/sim/sim_test.go +300 -0
  15. data/go/internal/frontend/acceptor.go +164 -0
  16. data/go/internal/frontend/altsvc.go +57 -0
  17. data/go/internal/frontend/altsvc_test.go +170 -0
  18. data/go/internal/frontend/bodypump.go +81 -0
  19. data/go/internal/frontend/env.go +224 -0
  20. data/go/internal/frontend/env_test.go +64 -0
  21. data/go/internal/frontend/handler.go +543 -0
  22. data/go/internal/frontend/handler_test.go +486 -0
  23. data/go/internal/frontend/hijack.go +108 -0
  24. data/go/internal/frontend/hijack_test.go +197 -0
  25. data/go/internal/frontend/hooks_test.go +283 -0
  26. data/go/internal/frontend/launcher_test.go +289 -0
  27. data/go/internal/frontend/listeners.go +196 -0
  28. data/go/internal/frontend/protocol_test.go +391 -0
  29. data/go/internal/frontend/ractor_shepherd.go +160 -0
  30. data/go/internal/frontend/ractor_smoke_test.go +168 -0
  31. data/go/internal/frontend/realcert_test.go +163 -0
  32. data/go/internal/frontend/rtbridge.go +410 -0
  33. data/go/internal/frontend/shepherd.go +188 -0
  34. data/go/internal/frontend/socket.go +37 -0
  35. data/go/internal/frontend/socketpair_test.go +34 -0
  36. data/go/internal/frontend/tlscert.go +184 -0
  37. data/go/internal/frontend/tlscert_test.go +81 -0
  38. data/go/internal/frontend/wscontrol.go +198 -0
  39. data/go/internal/metrics/collector.go +207 -0
  40. data/go/internal/metrics/endpoints.go +244 -0
  41. data/go/internal/metrics/gvl.go +136 -0
  42. data/go/internal/metrics/gvl_test.go +122 -0
  43. data/go/internal/metrics/hist.go +204 -0
  44. data/go/internal/metrics/hist_test.go +353 -0
  45. data/go/internal/metrics/window.go +120 -0
  46. data/go/internal/queue/drain_test.go +141 -0
  47. data/go/internal/queue/queue.go +297 -0
  48. data/go/internal/realtime/event.go +53 -0
  49. data/go/internal/realtime/hub.go +456 -0
  50. data/go/internal/realtime/hub_test.go +370 -0
  51. data/go/internal/realtime/id.go +69 -0
  52. data/go/internal/realtime/id_test.go +64 -0
  53. data/go/internal/websocket/frame.go +186 -0
  54. data/go/internal/websocket/serve.go +196 -0
  55. data/go/internal/websocket/transport.go +101 -0
  56. data/go/internal/webtransport/serve.go +169 -0
  57. data/go/internal/webtransport/transport.go +220 -0
  58. data/go/internal/wire/golden_test.go +250 -0
  59. data/go/internal/wire/rack_test.go +40 -0
  60. data/go/internal/wire/ractor_test.go +43 -0
  61. data/go/internal/wire/wire.go +401 -0
  62. data/go/vendor/github.com/dunglas/httpsfv/LICENSE +27 -0
  63. data/go/vendor/github.com/dunglas/httpsfv/README.md +25 -0
  64. data/go/vendor/github.com/dunglas/httpsfv/bareitem.go +115 -0
  65. data/go/vendor/github.com/dunglas/httpsfv/binary.go +59 -0
  66. data/go/vendor/github.com/dunglas/httpsfv/boolean.go +49 -0
  67. data/go/vendor/github.com/dunglas/httpsfv/date.go +41 -0
  68. data/go/vendor/github.com/dunglas/httpsfv/decimal.go +64 -0
  69. data/go/vendor/github.com/dunglas/httpsfv/decode.go +63 -0
  70. data/go/vendor/github.com/dunglas/httpsfv/dictionary.go +167 -0
  71. data/go/vendor/github.com/dunglas/httpsfv/displaystring.go +105 -0
  72. data/go/vendor/github.com/dunglas/httpsfv/encode.go +42 -0
  73. data/go/vendor/github.com/dunglas/httpsfv/innerlist.go +91 -0
  74. data/go/vendor/github.com/dunglas/httpsfv/integer.go +120 -0
  75. data/go/vendor/github.com/dunglas/httpsfv/item.go +73 -0
  76. data/go/vendor/github.com/dunglas/httpsfv/key.go +81 -0
  77. data/go/vendor/github.com/dunglas/httpsfv/list.go +99 -0
  78. data/go/vendor/github.com/dunglas/httpsfv/member.go +9 -0
  79. data/go/vendor/github.com/dunglas/httpsfv/params.go +143 -0
  80. data/go/vendor/github.com/dunglas/httpsfv/string.go +88 -0
  81. data/go/vendor/github.com/dunglas/httpsfv/token.go +71 -0
  82. data/go/vendor/github.com/dunglas/httpsfv/utils.go +16 -0
  83. data/go/vendor/github.com/quic-go/qpack/LICENSE.md +7 -0
  84. data/go/vendor/github.com/quic-go/qpack/README.md +21 -0
  85. data/go/vendor/github.com/quic-go/qpack/decoder.go +183 -0
  86. data/go/vendor/github.com/quic-go/qpack/encoder.go +95 -0
  87. data/go/vendor/github.com/quic-go/qpack/header_field.go +16 -0
  88. data/go/vendor/github.com/quic-go/qpack/static_table.go +255 -0
  89. data/go/vendor/github.com/quic-go/qpack/varint.go +69 -0
  90. data/go/vendor/github.com/quic-go/quic-go/FIPS140.md +37 -0
  91. data/go/vendor/github.com/quic-go/quic-go/FUZZING.md +59 -0
  92. data/go/vendor/github.com/quic-go/quic-go/LICENSE +21 -0
  93. data/go/vendor/github.com/quic-go/quic-go/README.md +65 -0
  94. data/go/vendor/github.com/quic-go/quic-go/SECURITY.md +14 -0
  95. data/go/vendor/github.com/quic-go/quic-go/buffer_pool.go +92 -0
  96. data/go/vendor/github.com/quic-go/quic-go/client.go +109 -0
  97. data/go/vendor/github.com/quic-go/quic-go/closed_conn.go +58 -0
  98. data/go/vendor/github.com/quic-go/quic-go/codecov.yml +23 -0
  99. data/go/vendor/github.com/quic-go/quic-go/config.go +129 -0
  100. data/go/vendor/github.com/quic-go/quic-go/conn_id_generator.go +212 -0
  101. data/go/vendor/github.com/quic-go/quic-go/conn_id_manager.go +321 -0
  102. data/go/vendor/github.com/quic-go/quic-go/connection.go +3150 -0
  103. data/go/vendor/github.com/quic-go/quic-go/connection_logging.go +315 -0
  104. data/go/vendor/github.com/quic-go/quic-go/crypto_stream.go +249 -0
  105. data/go/vendor/github.com/quic-go/quic-go/crypto_stream_manager.go +73 -0
  106. data/go/vendor/github.com/quic-go/quic-go/datagram_queue.go +137 -0
  107. data/go/vendor/github.com/quic-go/quic-go/errors.go +105 -0
  108. data/go/vendor/github.com/quic-go/quic-go/flow_controller_base.go +84 -0
  109. data/go/vendor/github.com/quic-go/quic-go/flow_controller_connection.go +186 -0
  110. data/go/vendor/github.com/quic-go/quic-go/flow_controller_stream.go +196 -0
  111. data/go/vendor/github.com/quic-go/quic-go/frame_sorter.go +274 -0
  112. data/go/vendor/github.com/quic-go/quic-go/framer.go +295 -0
  113. data/go/vendor/github.com/quic-go/quic-go/http3/README.md +9 -0
  114. data/go/vendor/github.com/quic-go/quic-go/http3/body.go +137 -0
  115. data/go/vendor/github.com/quic-go/quic-go/http3/capsule.go +148 -0
  116. data/go/vendor/github.com/quic-go/quic-go/http3/client.go +496 -0
  117. data/go/vendor/github.com/quic-go/quic-go/http3/conn.go +319 -0
  118. data/go/vendor/github.com/quic-go/quic-go/http3/error.go +63 -0
  119. data/go/vendor/github.com/quic-go/quic-go/http3/error_codes.go +84 -0
  120. data/go/vendor/github.com/quic-go/quic-go/http3/frames.go +327 -0
  121. data/go/vendor/github.com/quic-go/quic-go/http3/gzip_reader.go +39 -0
  122. data/go/vendor/github.com/quic-go/quic-go/http3/headers.go +429 -0
  123. data/go/vendor/github.com/quic-go/quic-go/http3/ip_addr.go +48 -0
  124. data/go/vendor/github.com/quic-go/quic-go/http3/mockgen.go +11 -0
  125. data/go/vendor/github.com/quic-go/quic-go/http3/qlog/event.go +138 -0
  126. data/go/vendor/github.com/quic-go/quic-go/http3/qlog/frame.go +220 -0
  127. data/go/vendor/github.com/quic-go/quic-go/http3/qlog/qlog_dir.go +15 -0
  128. data/go/vendor/github.com/quic-go/quic-go/http3/qlog.go +56 -0
  129. data/go/vendor/github.com/quic-go/quic-go/http3/request_writer.go +324 -0
  130. data/go/vendor/github.com/quic-go/quic-go/http3/response_writer.go +372 -0
  131. data/go/vendor/github.com/quic-go/quic-go/http3/server.go +738 -0
  132. data/go/vendor/github.com/quic-go/quic-go/http3/server_conn.go +259 -0
  133. data/go/vendor/github.com/quic-go/quic-go/http3/state_tracking_stream.go +173 -0
  134. data/go/vendor/github.com/quic-go/quic-go/http3/stream.go +406 -0
  135. data/go/vendor/github.com/quic-go/quic-go/http3/trace.go +105 -0
  136. data/go/vendor/github.com/quic-go/quic-go/http3/transport.go +538 -0
  137. data/go/vendor/github.com/quic-go/quic-go/interface.go +221 -0
  138. data/go/vendor/github.com/quic-go/quic-go/internal/ackhandler/ack_eliciting.go +33 -0
  139. data/go/vendor/github.com/quic-go/quic-go/internal/ackhandler/ecn.go +340 -0
  140. data/go/vendor/github.com/quic-go/quic-go/internal/ackhandler/frame.go +21 -0
  141. data/go/vendor/github.com/quic-go/quic-go/internal/ackhandler/interfaces.go +39 -0
  142. data/go/vendor/github.com/quic-go/quic-go/internal/ackhandler/lost_packet_tracker.go +73 -0
  143. data/go/vendor/github.com/quic-go/quic-go/internal/ackhandler/mockgen.go +6 -0
  144. data/go/vendor/github.com/quic-go/quic-go/internal/ackhandler/packet.go +60 -0
  145. data/go/vendor/github.com/quic-go/quic-go/internal/ackhandler/packet_number_generator.go +84 -0
  146. data/go/vendor/github.com/quic-go/quic-go/internal/ackhandler/received_packet_handler.go +119 -0
  147. data/go/vendor/github.com/quic-go/quic-go/internal/ackhandler/received_packet_history.go +159 -0
  148. data/go/vendor/github.com/quic-go/quic-go/internal/ackhandler/received_packet_tracker.go +228 -0
  149. data/go/vendor/github.com/quic-go/quic-go/internal/ackhandler/send_mode.go +46 -0
  150. data/go/vendor/github.com/quic-go/quic-go/internal/ackhandler/sent_packet_handler.go +1143 -0
  151. data/go/vendor/github.com/quic-go/quic-go/internal/ackhandler/sent_packet_history.go +274 -0
  152. data/go/vendor/github.com/quic-go/quic-go/internal/congestion/bandwidth.go +22 -0
  153. data/go/vendor/github.com/quic-go/quic-go/internal/congestion/clock.go +20 -0
  154. data/go/vendor/github.com/quic-go/quic-go/internal/congestion/cubic.go +214 -0
  155. data/go/vendor/github.com/quic-go/quic-go/internal/congestion/cubic_sender.go +330 -0
  156. data/go/vendor/github.com/quic-go/quic-go/internal/congestion/hybrid_slow_start.go +112 -0
  157. data/go/vendor/github.com/quic-go/quic-go/internal/congestion/interface.go +27 -0
  158. data/go/vendor/github.com/quic-go/quic-go/internal/congestion/pacer.go +110 -0
  159. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/aead.go +91 -0
  160. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/cipher_suite.go +114 -0
  161. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/cipher_suite_fips140.go +48 -0
  162. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/crypto_setup.go +718 -0
  163. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/fake_conn.go +21 -0
  164. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/fips140_go126.go +9 -0
  165. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/fips140_legacy.go +7 -0
  166. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/header_protector.go +134 -0
  167. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/hkdf.go +26 -0
  168. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/initial_aead.go +80 -0
  169. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/interface.go +140 -0
  170. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/quic_event_go125.go +11 -0
  171. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/quic_event_go126.go +11 -0
  172. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/retry_go125.go +68 -0
  173. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/retry_go126.go +70 -0
  174. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/session_ticket.go +55 -0
  175. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/tls_config_go126.go +54 -0
  176. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/tls_config_go127.go +24 -0
  177. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/token_generator.go +126 -0
  178. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/token_protector.go +78 -0
  179. data/go/vendor/github.com/quic-go/quic-go/internal/handshake/updatable_aead.go +372 -0
  180. data/go/vendor/github.com/quic-go/quic-go/internal/monotime/time.go +90 -0
  181. data/go/vendor/github.com/quic-go/quic-go/internal/protocol/connection_id.go +116 -0
  182. data/go/vendor/github.com/quic-go/quic-go/internal/protocol/encryption_level.go +65 -0
  183. data/go/vendor/github.com/quic-go/quic-go/internal/protocol/key_phase.go +36 -0
  184. data/go/vendor/github.com/quic-go/quic-go/internal/protocol/packet_number.go +57 -0
  185. data/go/vendor/github.com/quic-go/quic-go/internal/protocol/params.go +169 -0
  186. data/go/vendor/github.com/quic-go/quic-go/internal/protocol/perspective.go +26 -0
  187. data/go/vendor/github.com/quic-go/quic-go/internal/protocol/protocol.go +156 -0
  188. data/go/vendor/github.com/quic-go/quic-go/internal/protocol/stream.go +102 -0
  189. data/go/vendor/github.com/quic-go/quic-go/internal/protocol/version.go +115 -0
  190. data/go/vendor/github.com/quic-go/quic-go/internal/qerr/error_codes.go +87 -0
  191. data/go/vendor/github.com/quic-go/quic-go/internal/qerr/errors.go +134 -0
  192. data/go/vendor/github.com/quic-go/quic-go/internal/utils/buffered_write_closer.go +26 -0
  193. data/go/vendor/github.com/quic-go/quic-go/internal/utils/connstats.go +14 -0
  194. data/go/vendor/github.com/quic-go/quic-go/internal/utils/linkedlist/README.md +6 -0
  195. data/go/vendor/github.com/quic-go/quic-go/internal/utils/linkedlist/linkedlist.go +264 -0
  196. data/go/vendor/github.com/quic-go/quic-go/internal/utils/log.go +131 -0
  197. data/go/vendor/github.com/quic-go/quic-go/internal/utils/rand.go +29 -0
  198. data/go/vendor/github.com/quic-go/quic-go/internal/utils/ringbuffer/ringbuffer.go +96 -0
  199. data/go/vendor/github.com/quic-go/quic-go/internal/utils/rtt_stats.go +159 -0
  200. data/go/vendor/github.com/quic-go/quic-go/internal/wire/ack_frame.go +298 -0
  201. data/go/vendor/github.com/quic-go/quic-go/internal/wire/ack_frequency_frame.go +65 -0
  202. data/go/vendor/github.com/quic-go/quic-go/internal/wire/ack_range.go +14 -0
  203. data/go/vendor/github.com/quic-go/quic-go/internal/wire/connection_close_frame.go +75 -0
  204. data/go/vendor/github.com/quic-go/quic-go/internal/wire/crypto_frame.go +97 -0
  205. data/go/vendor/github.com/quic-go/quic-go/internal/wire/data_blocked_frame.go +29 -0
  206. data/go/vendor/github.com/quic-go/quic-go/internal/wire/datagram_frame.go +85 -0
  207. data/go/vendor/github.com/quic-go/quic-go/internal/wire/extended_header.go +164 -0
  208. data/go/vendor/github.com/quic-go/quic-go/internal/wire/frame.go +33 -0
  209. data/go/vendor/github.com/quic-go/quic-go/internal/wire/frame_parser.go +192 -0
  210. data/go/vendor/github.com/quic-go/quic-go/internal/wire/frame_type.go +81 -0
  211. data/go/vendor/github.com/quic-go/quic-go/internal/wire/handshake_done_frame.go +17 -0
  212. data/go/vendor/github.com/quic-go/quic-go/internal/wire/header.go +302 -0
  213. data/go/vendor/github.com/quic-go/quic-go/internal/wire/immediate_ack_frame.go +18 -0
  214. data/go/vendor/github.com/quic-go/quic-go/internal/wire/log.go +74 -0
  215. data/go/vendor/github.com/quic-go/quic-go/internal/wire/max_data_frame.go +33 -0
  216. data/go/vendor/github.com/quic-go/quic-go/internal/wire/max_stream_data_frame.go +43 -0
  217. data/go/vendor/github.com/quic-go/quic-go/internal/wire/max_streams_frame.go +50 -0
  218. data/go/vendor/github.com/quic-go/quic-go/internal/wire/new_connection_id_frame.go +80 -0
  219. data/go/vendor/github.com/quic-go/quic-go/internal/wire/new_token_frame.go +43 -0
  220. data/go/vendor/github.com/quic-go/quic-go/internal/wire/path_challenge_frame.go +32 -0
  221. data/go/vendor/github.com/quic-go/quic-go/internal/wire/path_response_frame.go +32 -0
  222. data/go/vendor/github.com/quic-go/quic-go/internal/wire/ping_frame.go +17 -0
  223. data/go/vendor/github.com/quic-go/quic-go/internal/wire/pool.go +33 -0
  224. data/go/vendor/github.com/quic-go/quic-go/internal/wire/reset_stream_frame.go +79 -0
  225. data/go/vendor/github.com/quic-go/quic-go/internal/wire/retire_connection_id_frame.go +30 -0
  226. data/go/vendor/github.com/quic-go/quic-go/internal/wire/short_header.go +62 -0
  227. data/go/vendor/github.com/quic-go/quic-go/internal/wire/stop_sending_frame.go +45 -0
  228. data/go/vendor/github.com/quic-go/quic-go/internal/wire/stream_data_blocked_frame.go +42 -0
  229. data/go/vendor/github.com/quic-go/quic-go/internal/wire/stream_frame.go +191 -0
  230. data/go/vendor/github.com/quic-go/quic-go/internal/wire/streams_blocked_frame.go +50 -0
  231. data/go/vendor/github.com/quic-go/quic-go/internal/wire/transport_parameters.go +593 -0
  232. data/go/vendor/github.com/quic-go/quic-go/internal/wire/version_negotiation.go +53 -0
  233. data/go/vendor/github.com/quic-go/quic-go/mockgen.go +47 -0
  234. data/go/vendor/github.com/quic-go/quic-go/mtu_discoverer.go +253 -0
  235. data/go/vendor/github.com/quic-go/quic-go/oss-fuzz.sh +52 -0
  236. data/go/vendor/github.com/quic-go/quic-go/packet_packer.go +1009 -0
  237. data/go/vendor/github.com/quic-go/quic-go/packet_unpacker.go +222 -0
  238. data/go/vendor/github.com/quic-go/quic-go/path_manager.go +206 -0
  239. data/go/vendor/github.com/quic-go/quic-go/path_manager_outgoing.go +314 -0
  240. data/go/vendor/github.com/quic-go/quic-go/qlog/event.go +849 -0
  241. data/go/vendor/github.com/quic-go/quic-go/qlog/frame.go +481 -0
  242. data/go/vendor/github.com/quic-go/quic-go/qlog/packet_header.go +96 -0
  243. data/go/vendor/github.com/quic-go/quic-go/qlog/qlog_dir.go +61 -0
  244. data/go/vendor/github.com/quic-go/quic-go/qlog/types.go +305 -0
  245. data/go/vendor/github.com/quic-go/quic-go/qlogwriter/jsontext/encoder.go +324 -0
  246. data/go/vendor/github.com/quic-go/quic-go/qlogwriter/trace.go +124 -0
  247. data/go/vendor/github.com/quic-go/quic-go/qlogwriter/writer.go +229 -0
  248. data/go/vendor/github.com/quic-go/quic-go/quicvarint/io.go +98 -0
  249. data/go/vendor/github.com/quic-go/quic-go/quicvarint/varint.go +180 -0
  250. data/go/vendor/github.com/quic-go/quic-go/receive_stream.go +578 -0
  251. data/go/vendor/github.com/quic-go/quic-go/retransmission_queue.go +158 -0
  252. data/go/vendor/github.com/quic-go/quic-go/send_conn.go +124 -0
  253. data/go/vendor/github.com/quic-go/quic-go/send_queue.go +112 -0
  254. data/go/vendor/github.com/quic-go/quic-go/send_stream.go +915 -0
  255. data/go/vendor/github.com/quic-go/quic-go/server.go +1119 -0
  256. data/go/vendor/github.com/quic-go/quic-go/sni.go +136 -0
  257. data/go/vendor/github.com/quic-go/quic-go/stateless_reset.go +42 -0
  258. data/go/vendor/github.com/quic-go/quic-go/stream.go +253 -0
  259. data/go/vendor/github.com/quic-go/quic-go/streams_map.go +356 -0
  260. data/go/vendor/github.com/quic-go/quic-go/streams_map_incoming.go +209 -0
  261. data/go/vendor/github.com/quic-go/quic-go/streams_map_outgoing.go +253 -0
  262. data/go/vendor/github.com/quic-go/quic-go/sys_conn.go +143 -0
  263. data/go/vendor/github.com/quic-go/quic-go/sys_conn_buffers.go +68 -0
  264. data/go/vendor/github.com/quic-go/quic-go/sys_conn_buffers_write.go +70 -0
  265. data/go/vendor/github.com/quic-go/quic-go/sys_conn_df.go +22 -0
  266. data/go/vendor/github.com/quic-go/quic-go/sys_conn_df_darwin.go +90 -0
  267. data/go/vendor/github.com/quic-go/quic-go/sys_conn_df_linux.go +42 -0
  268. data/go/vendor/github.com/quic-go/quic-go/sys_conn_df_windows.go +52 -0
  269. data/go/vendor/github.com/quic-go/quic-go/sys_conn_helper_darwin.go +38 -0
  270. data/go/vendor/github.com/quic-go/quic-go/sys_conn_helper_freebsd.go +33 -0
  271. data/go/vendor/github.com/quic-go/quic-go/sys_conn_helper_linux.go +156 -0
  272. data/go/vendor/github.com/quic-go/quic-go/sys_conn_helper_nonlinux.go +10 -0
  273. data/go/vendor/github.com/quic-go/quic-go/sys_conn_no_oob.go +21 -0
  274. data/go/vendor/github.com/quic-go/quic-go/sys_conn_oob.go +338 -0
  275. data/go/vendor/github.com/quic-go/quic-go/sys_conn_windows.go +42 -0
  276. data/go/vendor/github.com/quic-go/quic-go/token_store.go +116 -0
  277. data/go/vendor/github.com/quic-go/quic-go/transport.go +848 -0
  278. data/go/vendor/github.com/quic-go/webtransport-go/LICENSE +7 -0
  279. data/go/vendor/github.com/quic-go/webtransport-go/README.md +31 -0
  280. data/go/vendor/github.com/quic-go/webtransport-go/SECURITY.md +14 -0
  281. data/go/vendor/github.com/quic-go/webtransport-go/capsule.go +261 -0
  282. data/go/vendor/github.com/quic-go/webtransport-go/client_conn.go +289 -0
  283. data/go/vendor/github.com/quic-go/webtransport-go/codecov.yml +12 -0
  284. data/go/vendor/github.com/quic-go/webtransport-go/config.go +90 -0
  285. data/go/vendor/github.com/quic-go/webtransport-go/errors.go +96 -0
  286. data/go/vendor/github.com/quic-go/webtransport-go/flow_control.go +107 -0
  287. data/go/vendor/github.com/quic-go/webtransport-go/protocol.go +59 -0
  288. data/go/vendor/github.com/quic-go/webtransport-go/receive_stream.go +185 -0
  289. data/go/vendor/github.com/quic-go/webtransport-go/send_stream.go +322 -0
  290. data/go/vendor/github.com/quic-go/webtransport-go/server.go +533 -0
  291. data/go/vendor/github.com/quic-go/webtransport-go/session.go +463 -0
  292. data/go/vendor/github.com/quic-go/webtransport-go/session_manager.go +190 -0
  293. data/go/vendor/github.com/quic-go/webtransport-go/stream.go +147 -0
  294. data/go/vendor/github.com/quic-go/webtransport-go/streams_map_incoming.go +179 -0
  295. data/go/vendor/github.com/quic-go/webtransport-go/streams_map_outgoing.go +357 -0
  296. data/go/vendor/github.com/quic-go/webtransport-go/transport.go +126 -0
  297. data/go/vendor/golang.org/x/crypto/LICENSE +27 -0
  298. data/go/vendor/golang.org/x/crypto/PATENTS +22 -0
  299. data/go/vendor/golang.org/x/crypto/chacha20/chacha_arm64.go +16 -0
  300. data/go/vendor/golang.org/x/crypto/chacha20/chacha_arm64.s +307 -0
  301. data/go/vendor/golang.org/x/crypto/chacha20/chacha_generic.go +398 -0
  302. data/go/vendor/golang.org/x/crypto/chacha20/chacha_noasm.go +13 -0
  303. data/go/vendor/golang.org/x/crypto/chacha20/chacha_ppc64x.go +16 -0
  304. data/go/vendor/golang.org/x/crypto/chacha20/chacha_ppc64x.s +501 -0
  305. data/go/vendor/golang.org/x/crypto/chacha20/chacha_s390x.go +27 -0
  306. data/go/vendor/golang.org/x/crypto/chacha20/chacha_s390x.s +224 -0
  307. data/go/vendor/golang.org/x/crypto/chacha20/xor.go +42 -0
  308. data/go/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305.go +101 -0
  309. data/go/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.go +92 -0
  310. data/go/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.s +5230 -0
  311. data/go/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_generic.go +87 -0
  312. data/go/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_noasm.go +15 -0
  313. data/go/vendor/golang.org/x/crypto/chacha20poly1305/fips140only_compat.go +9 -0
  314. data/go/vendor/golang.org/x/crypto/chacha20poly1305/fips140only_go1.26.go +11 -0
  315. data/go/vendor/golang.org/x/crypto/chacha20poly1305/xchacha20poly1305.go +89 -0
  316. data/go/vendor/golang.org/x/crypto/internal/alias/alias.go +31 -0
  317. data/go/vendor/golang.org/x/crypto/internal/alias/alias_purego.go +34 -0
  318. data/go/vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go +9 -0
  319. data/go/vendor/golang.org/x/crypto/internal/poly1305/poly1305.go +99 -0
  320. data/go/vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.s +93 -0
  321. data/go/vendor/golang.org/x/crypto/internal/poly1305/sum_asm.go +47 -0
  322. data/go/vendor/golang.org/x/crypto/internal/poly1305/sum_generic.go +312 -0
  323. data/go/vendor/golang.org/x/crypto/internal/poly1305/sum_loong64.s +123 -0
  324. data/go/vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64x.s +187 -0
  325. data/go/vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.go +76 -0
  326. data/go/vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.s +503 -0
  327. data/go/vendor/golang.org/x/net/LICENSE +27 -0
  328. data/go/vendor/golang.org/x/net/PATENTS +22 -0
  329. data/go/vendor/golang.org/x/net/bpf/asm.go +41 -0
  330. data/go/vendor/golang.org/x/net/bpf/constants.go +222 -0
  331. data/go/vendor/golang.org/x/net/bpf/doc.go +87 -0
  332. data/go/vendor/golang.org/x/net/bpf/instructions.go +726 -0
  333. data/go/vendor/golang.org/x/net/bpf/setter.go +10 -0
  334. data/go/vendor/golang.org/x/net/bpf/vm.go +150 -0
  335. data/go/vendor/golang.org/x/net/bpf/vm_instructions.go +182 -0
  336. data/go/vendor/golang.org/x/net/http/httpguts/guts.go +50 -0
  337. data/go/vendor/golang.org/x/net/http/httpguts/httplex.go +347 -0
  338. data/go/vendor/golang.org/x/net/http2/README.md +19 -0
  339. data/go/vendor/golang.org/x/net/http2/ascii.go +53 -0
  340. data/go/vendor/golang.org/x/net/http2/ciphers.go +641 -0
  341. data/go/vendor/golang.org/x/net/http2/client_conn_pool.go +301 -0
  342. data/go/vendor/golang.org/x/net/http2/client_priority_go126.go +20 -0
  343. data/go/vendor/golang.org/x/net/http2/client_priority_go127.go +13 -0
  344. data/go/vendor/golang.org/x/net/http2/clientconn.go +57 -0
  345. data/go/vendor/golang.org/x/net/http2/config.go +171 -0
  346. data/go/vendor/golang.org/x/net/http2/config_go125.go +15 -0
  347. data/go/vendor/golang.org/x/net/http2/config_go126.go +15 -0
  348. data/go/vendor/golang.org/x/net/http2/databuffer.go +149 -0
  349. data/go/vendor/golang.org/x/net/http2/errors.go +145 -0
  350. data/go/vendor/golang.org/x/net/http2/flow.go +120 -0
  351. data/go/vendor/golang.org/x/net/http2/frame.go +1871 -0
  352. data/go/vendor/golang.org/x/net/http2/gotrack.go +181 -0
  353. data/go/vendor/golang.org/x/net/http2/h2c/h2c.go +256 -0
  354. data/go/vendor/golang.org/x/net/http2/hpack/encode.go +245 -0
  355. data/go/vendor/golang.org/x/net/http2/hpack/hpack.go +523 -0
  356. data/go/vendor/golang.org/x/net/http2/hpack/huffman.go +226 -0
  357. data/go/vendor/golang.org/x/net/http2/hpack/static_table.go +188 -0
  358. data/go/vendor/golang.org/x/net/http2/hpack/tables.go +403 -0
  359. data/go/vendor/golang.org/x/net/http2/http2.go +415 -0
  360. data/go/vendor/golang.org/x/net/http2/pipe.go +184 -0
  361. data/go/vendor/golang.org/x/net/http2/server.go +3217 -0
  362. data/go/vendor/golang.org/x/net/http2/server_common.go +221 -0
  363. data/go/vendor/golang.org/x/net/http2/server_wrap.go +217 -0
  364. data/go/vendor/golang.org/x/net/http2/transport.go +3036 -0
  365. data/go/vendor/golang.org/x/net/http2/transport_common.go +447 -0
  366. data/go/vendor/golang.org/x/net/http2/transport_wrap.go +394 -0
  367. data/go/vendor/golang.org/x/net/http2/unencrypted.go +32 -0
  368. data/go/vendor/golang.org/x/net/http2/write.go +381 -0
  369. data/go/vendor/golang.org/x/net/http2/writesched.go +252 -0
  370. data/go/vendor/golang.org/x/net/http2/writesched_common.go +90 -0
  371. data/go/vendor/golang.org/x/net/http2/writesched_priority_rfc7540.go +420 -0
  372. data/go/vendor/golang.org/x/net/http2/writesched_priority_rfc9218.go +226 -0
  373. data/go/vendor/golang.org/x/net/http2/writesched_random.go +81 -0
  374. data/go/vendor/golang.org/x/net/http2/writesched_roundrobin.go +121 -0
  375. data/go/vendor/golang.org/x/net/idna/idna.go +884 -0
  376. data/go/vendor/golang.org/x/net/idna/punycode.go +220 -0
  377. data/go/vendor/golang.org/x/net/idna/tables15.0.0.go +5144 -0
  378. data/go/vendor/golang.org/x/net/idna/tables17.0.0.go +5302 -0
  379. data/go/vendor/golang.org/x/net/idna/trie.go +51 -0
  380. data/go/vendor/golang.org/x/net/idna/trieval.go +119 -0
  381. data/go/vendor/golang.org/x/net/internal/httpcommon/ascii.go +53 -0
  382. data/go/vendor/golang.org/x/net/internal/httpcommon/headermap.go +115 -0
  383. data/go/vendor/golang.org/x/net/internal/httpcommon/request.go +475 -0
  384. data/go/vendor/golang.org/x/net/internal/httpsfv/httpsfv.go +665 -0
  385. data/go/vendor/golang.org/x/net/internal/iana/const.go +223 -0
  386. data/go/vendor/golang.org/x/net/internal/socket/cmsghdr.go +11 -0
  387. data/go/vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go +13 -0
  388. data/go/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_32bit.go +13 -0
  389. data/go/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go +13 -0
  390. data/go/vendor/golang.org/x/net/internal/socket/cmsghdr_solaris_64bit.go +13 -0
  391. data/go/vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go +27 -0
  392. data/go/vendor/golang.org/x/net/internal/socket/cmsghdr_unix.go +21 -0
  393. data/go/vendor/golang.org/x/net/internal/socket/cmsghdr_zos_s390x.go +11 -0
  394. data/go/vendor/golang.org/x/net/internal/socket/complete_dontwait.go +25 -0
  395. data/go/vendor/golang.org/x/net/internal/socket/complete_nodontwait.go +21 -0
  396. data/go/vendor/golang.org/x/net/internal/socket/empty.s +7 -0
  397. data/go/vendor/golang.org/x/net/internal/socket/error_unix.go +31 -0
  398. data/go/vendor/golang.org/x/net/internal/socket/error_windows.go +26 -0
  399. data/go/vendor/golang.org/x/net/internal/socket/iovec_32bit.go +18 -0
  400. data/go/vendor/golang.org/x/net/internal/socket/iovec_64bit.go +18 -0
  401. data/go/vendor/golang.org/x/net/internal/socket/iovec_solaris_64bit.go +18 -0
  402. data/go/vendor/golang.org/x/net/internal/socket/iovec_stub.go +11 -0
  403. data/go/vendor/golang.org/x/net/internal/socket/mmsghdr_stub.go +21 -0
  404. data/go/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go +195 -0
  405. data/go/vendor/golang.org/x/net/internal/socket/msghdr_bsd.go +39 -0
  406. data/go/vendor/golang.org/x/net/internal/socket/msghdr_bsdvar.go +16 -0
  407. data/go/vendor/golang.org/x/net/internal/socket/msghdr_linux.go +36 -0
  408. data/go/vendor/golang.org/x/net/internal/socket/msghdr_linux_32bit.go +23 -0
  409. data/go/vendor/golang.org/x/net/internal/socket/msghdr_linux_64bit.go +23 -0
  410. data/go/vendor/golang.org/x/net/internal/socket/msghdr_openbsd.go +14 -0
  411. data/go/vendor/golang.org/x/net/internal/socket/msghdr_solaris_64bit.go +38 -0
  412. data/go/vendor/golang.org/x/net/internal/socket/msghdr_stub.go +14 -0
  413. data/go/vendor/golang.org/x/net/internal/socket/msghdr_zos_s390x.go +35 -0
  414. data/go/vendor/golang.org/x/net/internal/socket/norace.go +12 -0
  415. data/go/vendor/golang.org/x/net/internal/socket/race.go +37 -0
  416. data/go/vendor/golang.org/x/net/internal/socket/rawconn.go +91 -0
  417. data/go/vendor/golang.org/x/net/internal/socket/rawconn_mmsg.go +53 -0
  418. data/go/vendor/golang.org/x/net/internal/socket/rawconn_msg.go +59 -0
  419. data/go/vendor/golang.org/x/net/internal/socket/rawconn_nommsg.go +15 -0
  420. data/go/vendor/golang.org/x/net/internal/socket/rawconn_nomsg.go +15 -0
  421. data/go/vendor/golang.org/x/net/internal/socket/socket.go +281 -0
  422. data/go/vendor/golang.org/x/net/internal/socket/sys_bsd.go +15 -0
  423. data/go/vendor/golang.org/x/net/internal/socket/sys_const_unix.go +20 -0
  424. data/go/vendor/golang.org/x/net/internal/socket/sys_linux.go +22 -0
  425. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_386.go +28 -0
  426. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_386.s +11 -0
  427. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_amd64.go +10 -0
  428. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_arm.go +10 -0
  429. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_arm64.go +10 -0
  430. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_loong64.go +12 -0
  431. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_mips.go +10 -0
  432. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_mips64.go +10 -0
  433. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_mips64le.go +10 -0
  434. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_mipsle.go +10 -0
  435. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_ppc.go +10 -0
  436. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64.go +10 -0
  437. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64le.go +10 -0
  438. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_riscv64.go +12 -0
  439. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.go +28 -0
  440. data/go/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.s +11 -0
  441. data/go/vendor/golang.org/x/net/internal/socket/sys_netbsd.go +25 -0
  442. data/go/vendor/golang.org/x/net/internal/socket/sys_posix.go +184 -0
  443. data/go/vendor/golang.org/x/net/internal/socket/sys_stub.go +52 -0
  444. data/go/vendor/golang.org/x/net/internal/socket/sys_unix.go +121 -0
  445. data/go/vendor/golang.org/x/net/internal/socket/sys_windows.go +55 -0
  446. data/go/vendor/golang.org/x/net/internal/socket/sys_zos_s390x.go +66 -0
  447. data/go/vendor/golang.org/x/net/internal/socket/sys_zos_s390x.s +11 -0
  448. data/go/vendor/golang.org/x/net/internal/socket/zsys_aix_ppc64.go +39 -0
  449. data/go/vendor/golang.org/x/net/internal/socket/zsys_darwin_amd64.go +32 -0
  450. data/go/vendor/golang.org/x/net/internal/socket/zsys_darwin_arm64.go +32 -0
  451. data/go/vendor/golang.org/x/net/internal/socket/zsys_dragonfly_amd64.go +32 -0
  452. data/go/vendor/golang.org/x/net/internal/socket/zsys_freebsd_386.go +30 -0
  453. data/go/vendor/golang.org/x/net/internal/socket/zsys_freebsd_amd64.go +32 -0
  454. data/go/vendor/golang.org/x/net/internal/socket/zsys_freebsd_arm.go +30 -0
  455. data/go/vendor/golang.org/x/net/internal/socket/zsys_freebsd_arm64.go +32 -0
  456. data/go/vendor/golang.org/x/net/internal/socket/zsys_freebsd_riscv64.go +30 -0
  457. data/go/vendor/golang.org/x/net/internal/socket/zsys_linux_386.go +35 -0
  458. data/go/vendor/golang.org/x/net/internal/socket/zsys_linux_amd64.go +38 -0
  459. data/go/vendor/golang.org/x/net/internal/socket/zsys_linux_arm.go +35 -0
  460. data/go/vendor/golang.org/x/net/internal/socket/zsys_linux_arm64.go +38 -0
  461. data/go/vendor/golang.org/x/net/internal/socket/zsys_linux_loong64.go +39 -0
  462. data/go/vendor/golang.org/x/net/internal/socket/zsys_linux_mips.go +35 -0
  463. data/go/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64.go +38 -0
  464. data/go/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64le.go +38 -0
  465. data/go/vendor/golang.org/x/net/internal/socket/zsys_linux_mipsle.go +35 -0
  466. data/go/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc.go +35 -0
  467. data/go/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64.go +38 -0
  468. data/go/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64le.go +38 -0
  469. data/go/vendor/golang.org/x/net/internal/socket/zsys_linux_riscv64.go +39 -0
  470. data/go/vendor/golang.org/x/net/internal/socket/zsys_linux_s390x.go +38 -0
  471. data/go/vendor/golang.org/x/net/internal/socket/zsys_netbsd_386.go +35 -0
  472. data/go/vendor/golang.org/x/net/internal/socket/zsys_netbsd_amd64.go +38 -0
  473. data/go/vendor/golang.org/x/net/internal/socket/zsys_netbsd_arm.go +35 -0
  474. data/go/vendor/golang.org/x/net/internal/socket/zsys_netbsd_arm64.go +38 -0
  475. data/go/vendor/golang.org/x/net/internal/socket/zsys_openbsd_386.go +30 -0
  476. data/go/vendor/golang.org/x/net/internal/socket/zsys_openbsd_amd64.go +32 -0
  477. data/go/vendor/golang.org/x/net/internal/socket/zsys_openbsd_arm.go +30 -0
  478. data/go/vendor/golang.org/x/net/internal/socket/zsys_openbsd_arm64.go +32 -0
  479. data/go/vendor/golang.org/x/net/internal/socket/zsys_openbsd_mips64.go +30 -0
  480. data/go/vendor/golang.org/x/net/internal/socket/zsys_openbsd_ppc64.go +30 -0
  481. data/go/vendor/golang.org/x/net/internal/socket/zsys_openbsd_riscv64.go +30 -0
  482. data/go/vendor/golang.org/x/net/internal/socket/zsys_solaris_amd64.go +32 -0
  483. data/go/vendor/golang.org/x/net/internal/socket/zsys_zos_s390x.go +28 -0
  484. data/go/vendor/golang.org/x/net/ipv4/batch.go +194 -0
  485. data/go/vendor/golang.org/x/net/ipv4/control.go +144 -0
  486. data/go/vendor/golang.org/x/net/ipv4/control_bsd.go +43 -0
  487. data/go/vendor/golang.org/x/net/ipv4/control_pktinfo.go +41 -0
  488. data/go/vendor/golang.org/x/net/ipv4/control_stub.go +13 -0
  489. data/go/vendor/golang.org/x/net/ipv4/control_unix.go +75 -0
  490. data/go/vendor/golang.org/x/net/ipv4/control_windows.go +12 -0
  491. data/go/vendor/golang.org/x/net/ipv4/control_zos.go +88 -0
  492. data/go/vendor/golang.org/x/net/ipv4/dgramopt.go +264 -0
  493. data/go/vendor/golang.org/x/net/ipv4/doc.go +240 -0
  494. data/go/vendor/golang.org/x/net/ipv4/endpoint.go +186 -0
  495. data/go/vendor/golang.org/x/net/ipv4/genericopt.go +55 -0
  496. data/go/vendor/golang.org/x/net/ipv4/header.go +170 -0
  497. data/go/vendor/golang.org/x/net/ipv4/helper.go +77 -0
  498. data/go/vendor/golang.org/x/net/ipv4/iana.go +38 -0
  499. data/go/vendor/golang.org/x/net/ipv4/icmp.go +57 -0
  500. data/go/vendor/golang.org/x/net/ipv4/icmp_linux.go +25 -0
  501. data/go/vendor/golang.org/x/net/ipv4/icmp_stub.go +25 -0
  502. data/go/vendor/golang.org/x/net/ipv4/packet.go +117 -0
  503. data/go/vendor/golang.org/x/net/ipv4/payload.go +23 -0
  504. data/go/vendor/golang.org/x/net/ipv4/payload_cmsg.go +84 -0
  505. data/go/vendor/golang.org/x/net/ipv4/payload_nocmsg.go +39 -0
  506. data/go/vendor/golang.org/x/net/ipv4/sockopt.go +44 -0
  507. data/go/vendor/golang.org/x/net/ipv4/sockopt_posix.go +71 -0
  508. data/go/vendor/golang.org/x/net/ipv4/sockopt_stub.go +42 -0
  509. data/go/vendor/golang.org/x/net/ipv4/sys_aix.go +43 -0
  510. data/go/vendor/golang.org/x/net/ipv4/sys_asmreq.go +122 -0
  511. data/go/vendor/golang.org/x/net/ipv4/sys_asmreq_stub.go +25 -0
  512. data/go/vendor/golang.org/x/net/ipv4/sys_asmreqn.go +44 -0
  513. data/go/vendor/golang.org/x/net/ipv4/sys_asmreqn_stub.go +21 -0
  514. data/go/vendor/golang.org/x/net/ipv4/sys_bpf.go +24 -0
  515. data/go/vendor/golang.org/x/net/ipv4/sys_bpf_stub.go +16 -0
  516. data/go/vendor/golang.org/x/net/ipv4/sys_bsd.go +41 -0
  517. data/go/vendor/golang.org/x/net/ipv4/sys_darwin.go +69 -0
  518. data/go/vendor/golang.org/x/net/ipv4/sys_dragonfly.go +39 -0
  519. data/go/vendor/golang.org/x/net/ipv4/sys_freebsd.go +80 -0
  520. data/go/vendor/golang.org/x/net/ipv4/sys_linux.go +61 -0
  521. data/go/vendor/golang.org/x/net/ipv4/sys_solaris.go +61 -0
  522. data/go/vendor/golang.org/x/net/ipv4/sys_ssmreq.go +52 -0
  523. data/go/vendor/golang.org/x/net/ipv4/sys_ssmreq_stub.go +21 -0
  524. data/go/vendor/golang.org/x/net/ipv4/sys_stub.go +13 -0
  525. data/go/vendor/golang.org/x/net/ipv4/sys_windows.go +44 -0
  526. data/go/vendor/golang.org/x/net/ipv4/sys_zos.go +57 -0
  527. data/go/vendor/golang.org/x/net/ipv4/zsys_aix_ppc64.go +16 -0
  528. data/go/vendor/golang.org/x/net/ipv4/zsys_darwin.go +59 -0
  529. data/go/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go +13 -0
  530. data/go/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go +52 -0
  531. data/go/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go +54 -0
  532. data/go/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go +54 -0
  533. data/go/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm64.go +52 -0
  534. data/go/vendor/golang.org/x/net/ipv4/zsys_freebsd_riscv64.go +52 -0
  535. data/go/vendor/golang.org/x/net/ipv4/zsys_linux_386.go +72 -0
  536. data/go/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go +74 -0
  537. data/go/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go +72 -0
  538. data/go/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go +74 -0
  539. data/go/vendor/golang.org/x/net/ipv4/zsys_linux_loong64.go +76 -0
  540. data/go/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go +72 -0
  541. data/go/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go +74 -0
  542. data/go/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go +74 -0
  543. data/go/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go +72 -0
  544. data/go/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go +72 -0
  545. data/go/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go +74 -0
  546. data/go/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go +74 -0
  547. data/go/vendor/golang.org/x/net/ipv4/zsys_linux_riscv64.go +76 -0
  548. data/go/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go +74 -0
  549. data/go/vendor/golang.org/x/net/ipv4/zsys_netbsd.go +13 -0
  550. data/go/vendor/golang.org/x/net/ipv4/zsys_openbsd.go +13 -0
  551. data/go/vendor/golang.org/x/net/ipv4/zsys_solaris.go +57 -0
  552. data/go/vendor/golang.org/x/net/ipv4/zsys_zos_s390x.go +56 -0
  553. data/go/vendor/golang.org/x/net/ipv6/batch.go +116 -0
  554. data/go/vendor/golang.org/x/net/ipv6/control.go +187 -0
  555. data/go/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go +51 -0
  556. data/go/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go +97 -0
  557. data/go/vendor/golang.org/x/net/ipv6/control_stub.go +13 -0
  558. data/go/vendor/golang.org/x/net/ipv6/control_unix.go +55 -0
  559. data/go/vendor/golang.org/x/net/ipv6/control_windows.go +12 -0
  560. data/go/vendor/golang.org/x/net/ipv6/dgramopt.go +301 -0
  561. data/go/vendor/golang.org/x/net/ipv6/doc.go +239 -0
  562. data/go/vendor/golang.org/x/net/ipv6/endpoint.go +127 -0
  563. data/go/vendor/golang.org/x/net/ipv6/genericopt.go +56 -0
  564. data/go/vendor/golang.org/x/net/ipv6/header.go +55 -0
  565. data/go/vendor/golang.org/x/net/ipv6/helper.go +58 -0
  566. data/go/vendor/golang.org/x/net/ipv6/iana.go +86 -0
  567. data/go/vendor/golang.org/x/net/ipv6/icmp.go +60 -0
  568. data/go/vendor/golang.org/x/net/ipv6/icmp_bsd.go +29 -0
  569. data/go/vendor/golang.org/x/net/ipv6/icmp_linux.go +27 -0
  570. data/go/vendor/golang.org/x/net/ipv6/icmp_solaris.go +27 -0
  571. data/go/vendor/golang.org/x/net/ipv6/icmp_stub.go +23 -0
  572. data/go/vendor/golang.org/x/net/ipv6/icmp_windows.go +22 -0
  573. data/go/vendor/golang.org/x/net/ipv6/icmp_zos.go +29 -0
  574. data/go/vendor/golang.org/x/net/ipv6/payload.go +23 -0
  575. data/go/vendor/golang.org/x/net/ipv6/payload_cmsg.go +70 -0
  576. data/go/vendor/golang.org/x/net/ipv6/payload_nocmsg.go +38 -0
  577. data/go/vendor/golang.org/x/net/ipv6/sockopt.go +43 -0
  578. data/go/vendor/golang.org/x/net/ipv6/sockopt_posix.go +89 -0
  579. data/go/vendor/golang.org/x/net/ipv6/sockopt_stub.go +46 -0
  580. data/go/vendor/golang.org/x/net/ipv6/sys_aix.go +79 -0
  581. data/go/vendor/golang.org/x/net/ipv6/sys_asmreq.go +24 -0
  582. data/go/vendor/golang.org/x/net/ipv6/sys_asmreq_stub.go +17 -0
  583. data/go/vendor/golang.org/x/net/ipv6/sys_bpf.go +24 -0
  584. data/go/vendor/golang.org/x/net/ipv6/sys_bpf_stub.go +16 -0
  585. data/go/vendor/golang.org/x/net/ipv6/sys_bsd.go +59 -0
  586. data/go/vendor/golang.org/x/net/ipv6/sys_darwin.go +80 -0
  587. data/go/vendor/golang.org/x/net/ipv6/sys_freebsd.go +94 -0
  588. data/go/vendor/golang.org/x/net/ipv6/sys_linux.go +76 -0
  589. data/go/vendor/golang.org/x/net/ipv6/sys_solaris.go +76 -0
  590. data/go/vendor/golang.org/x/net/ipv6/sys_ssmreq.go +54 -0
  591. data/go/vendor/golang.org/x/net/ipv6/sys_ssmreq_stub.go +21 -0
  592. data/go/vendor/golang.org/x/net/ipv6/sys_stub.go +13 -0
  593. data/go/vendor/golang.org/x/net/ipv6/sys_windows.go +68 -0
  594. data/go/vendor/golang.org/x/net/ipv6/sys_zos.go +72 -0
  595. data/go/vendor/golang.org/x/net/ipv6/zsys_aix_ppc64.go +68 -0
  596. data/go/vendor/golang.org/x/net/ipv6/zsys_darwin.go +64 -0
  597. data/go/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go +42 -0
  598. data/go/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go +64 -0
  599. data/go/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go +66 -0
  600. data/go/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go +66 -0
  601. data/go/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm64.go +64 -0
  602. data/go/vendor/golang.org/x/net/ipv6/zsys_freebsd_riscv64.go +64 -0
  603. data/go/vendor/golang.org/x/net/ipv6/zsys_linux_386.go +72 -0
  604. data/go/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go +74 -0
  605. data/go/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go +72 -0
  606. data/go/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go +74 -0
  607. data/go/vendor/golang.org/x/net/ipv6/zsys_linux_loong64.go +76 -0
  608. data/go/vendor/golang.org/x/net/ipv6/zsys_linux_mips.go +72 -0
  609. data/go/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go +74 -0
  610. data/go/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go +74 -0
  611. data/go/vendor/golang.org/x/net/ipv6/zsys_linux_mipsle.go +72 -0
  612. data/go/vendor/golang.org/x/net/ipv6/zsys_linux_ppc.go +72 -0
  613. data/go/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go +74 -0
  614. data/go/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go +74 -0
  615. data/go/vendor/golang.org/x/net/ipv6/zsys_linux_riscv64.go +76 -0
  616. data/go/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go +74 -0
  617. data/go/vendor/golang.org/x/net/ipv6/zsys_netbsd.go +42 -0
  618. data/go/vendor/golang.org/x/net/ipv6/zsys_openbsd.go +42 -0
  619. data/go/vendor/golang.org/x/net/ipv6/zsys_solaris.go +63 -0
  620. data/go/vendor/golang.org/x/net/ipv6/zsys_zos_s390x.go +62 -0
  621. data/go/vendor/golang.org/x/sys/LICENSE +27 -0
  622. data/go/vendor/golang.org/x/sys/PATENTS +22 -0
  623. data/go/vendor/golang.org/x/sys/cpu/asm_aix_ppc64.s +17 -0
  624. data/go/vendor/golang.org/x/sys/cpu/asm_darwin_arm64_gc.s +12 -0
  625. data/go/vendor/golang.org/x/sys/cpu/asm_darwin_x86_gc.s +17 -0
  626. data/go/vendor/golang.org/x/sys/cpu/byteorder.go +66 -0
  627. data/go/vendor/golang.org/x/sys/cpu/cpu.go +343 -0
  628. data/go/vendor/golang.org/x/sys/cpu/cpu_aix.go +33 -0
  629. data/go/vendor/golang.org/x/sys/cpu/cpu_arm.go +73 -0
  630. data/go/vendor/golang.org/x/sys/cpu/cpu_arm64.go +191 -0
  631. data/go/vendor/golang.org/x/sys/cpu/cpu_arm64.s +35 -0
  632. data/go/vendor/golang.org/x/sys/cpu/cpu_darwin_arm64.go +67 -0
  633. data/go/vendor/golang.org/x/sys/cpu/cpu_darwin_arm64_other.go +31 -0
  634. data/go/vendor/golang.org/x/sys/cpu/cpu_darwin_x86.go +61 -0
  635. data/go/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go +12 -0
  636. data/go/vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go +21 -0
  637. data/go/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go +15 -0
  638. data/go/vendor/golang.org/x/sys/cpu/cpu_gc_x86.s +26 -0
  639. data/go/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go +12 -0
  640. data/go/vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go +22 -0
  641. data/go/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c +37 -0
  642. data/go/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go +25 -0
  643. data/go/vendor/golang.org/x/sys/cpu/cpu_linux.go +15 -0
  644. data/go/vendor/golang.org/x/sys/cpu/cpu_linux_arm.go +39 -0
  645. data/go/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go +120 -0
  646. data/go/vendor/golang.org/x/sys/cpu/cpu_linux_loong64.go +22 -0
  647. data/go/vendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go +22 -0
  648. data/go/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go +9 -0
  649. data/go/vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go +30 -0
  650. data/go/vendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go +162 -0
  651. data/go/vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go +40 -0
  652. data/go/vendor/golang.org/x/sys/cpu/cpu_loong64.go +62 -0
  653. data/go/vendor/golang.org/x/sys/cpu/cpu_loong64.s +13 -0
  654. data/go/vendor/golang.org/x/sys/cpu/cpu_mips64x.go +15 -0
  655. data/go/vendor/golang.org/x/sys/cpu/cpu_mipsx.go +11 -0
  656. data/go/vendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go +173 -0
  657. data/go/vendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.go +65 -0
  658. data/go/vendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.s +11 -0
  659. data/go/vendor/golang.org/x/sys/cpu/cpu_other_arm.go +9 -0
  660. data/go/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go +11 -0
  661. data/go/vendor/golang.org/x/sys/cpu/cpu_other_mips64x.go +11 -0
  662. data/go/vendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go +12 -0
  663. data/go/vendor/golang.org/x/sys/cpu/cpu_other_riscv64.go +11 -0
  664. data/go/vendor/golang.org/x/sys/cpu/cpu_other_x86.go +11 -0
  665. data/go/vendor/golang.org/x/sys/cpu/cpu_ppc64x.go +16 -0
  666. data/go/vendor/golang.org/x/sys/cpu/cpu_riscv64.go +33 -0
  667. data/go/vendor/golang.org/x/sys/cpu/cpu_s390x.go +172 -0
  668. data/go/vendor/golang.org/x/sys/cpu/cpu_s390x.s +57 -0
  669. data/go/vendor/golang.org/x/sys/cpu/cpu_wasm.go +17 -0
  670. data/go/vendor/golang.org/x/sys/cpu/cpu_windows.go +26 -0
  671. data/go/vendor/golang.org/x/sys/cpu/cpu_windows_arm64.go +38 -0
  672. data/go/vendor/golang.org/x/sys/cpu/cpu_x86.go +236 -0
  673. data/go/vendor/golang.org/x/sys/cpu/cpu_zos.go +10 -0
  674. data/go/vendor/golang.org/x/sys/cpu/cpu_zos_s390x.go +25 -0
  675. data/go/vendor/golang.org/x/sys/cpu/endian_big.go +10 -0
  676. data/go/vendor/golang.org/x/sys/cpu/endian_little.go +10 -0
  677. data/go/vendor/golang.org/x/sys/cpu/hwcap_linux.go +71 -0
  678. data/go/vendor/golang.org/x/sys/cpu/parse.go +55 -0
  679. data/go/vendor/golang.org/x/sys/cpu/proc_cpuinfo_linux.go +53 -0
  680. data/go/vendor/golang.org/x/sys/cpu/runtime_auxv.go +16 -0
  681. data/go/vendor/golang.org/x/sys/cpu/runtime_auxv_go121.go +18 -0
  682. data/go/vendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go +26 -0
  683. data/go/vendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go +35 -0
  684. data/go/vendor/golang.org/x/sys/cpu/syscall_darwin_arm64_gc.go +54 -0
  685. data/go/vendor/golang.org/x/sys/cpu/syscall_darwin_x86_gc.go +98 -0
  686. data/go/vendor/golang.org/x/sys/cpu/zcpu_windows.go +48 -0
  687. data/go/vendor/golang.org/x/sys/unix/README.md +184 -0
  688. data/go/vendor/golang.org/x/sys/unix/affinity_linux.go +189 -0
  689. data/go/vendor/golang.org/x/sys/unix/aliases.go +13 -0
  690. data/go/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s +17 -0
  691. data/go/vendor/golang.org/x/sys/unix/asm_bsd_386.s +27 -0
  692. data/go/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s +27 -0
  693. data/go/vendor/golang.org/x/sys/unix/asm_bsd_arm.s +27 -0
  694. data/go/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s +27 -0
  695. data/go/vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s +29 -0
  696. data/go/vendor/golang.org/x/sys/unix/asm_bsd_riscv64.s +27 -0
  697. data/go/vendor/golang.org/x/sys/unix/asm_linux_386.s +65 -0
  698. data/go/vendor/golang.org/x/sys/unix/asm_linux_amd64.s +57 -0
  699. data/go/vendor/golang.org/x/sys/unix/asm_linux_arm.s +56 -0
  700. data/go/vendor/golang.org/x/sys/unix/asm_linux_arm64.s +50 -0
  701. data/go/vendor/golang.org/x/sys/unix/asm_linux_loong64.s +51 -0
  702. data/go/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s +54 -0
  703. data/go/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s +52 -0
  704. data/go/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s +42 -0
  705. data/go/vendor/golang.org/x/sys/unix/asm_linux_riscv64.s +47 -0
  706. data/go/vendor/golang.org/x/sys/unix/asm_linux_s390x.s +54 -0
  707. data/go/vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s +29 -0
  708. data/go/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s +17 -0
  709. data/go/vendor/golang.org/x/sys/unix/asm_zos_s390x.s +382 -0
  710. data/go/vendor/golang.org/x/sys/unix/auxv.go +36 -0
  711. data/go/vendor/golang.org/x/sys/unix/auxv_unsupported.go +13 -0
  712. data/go/vendor/golang.org/x/sys/unix/bluetooth_linux.go +36 -0
  713. data/go/vendor/golang.org/x/sys/unix/bpxsvc_zos.go +657 -0
  714. data/go/vendor/golang.org/x/sys/unix/bpxsvc_zos.s +192 -0
  715. data/go/vendor/golang.org/x/sys/unix/cap_freebsd.go +195 -0
  716. data/go/vendor/golang.org/x/sys/unix/constants.go +13 -0
  717. data/go/vendor/golang.org/x/sys/unix/dev_aix_ppc.go +26 -0
  718. data/go/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go +28 -0
  719. data/go/vendor/golang.org/x/sys/unix/dev_darwin.go +24 -0
  720. data/go/vendor/golang.org/x/sys/unix/dev_dragonfly.go +30 -0
  721. data/go/vendor/golang.org/x/sys/unix/dev_freebsd.go +30 -0
  722. data/go/vendor/golang.org/x/sys/unix/dev_linux.go +42 -0
  723. data/go/vendor/golang.org/x/sys/unix/dev_netbsd.go +29 -0
  724. data/go/vendor/golang.org/x/sys/unix/dev_openbsd.go +29 -0
  725. data/go/vendor/golang.org/x/sys/unix/dev_zos.go +28 -0
  726. data/go/vendor/golang.org/x/sys/unix/dirent.go +102 -0
  727. data/go/vendor/golang.org/x/sys/unix/endian_big.go +9 -0
  728. data/go/vendor/golang.org/x/sys/unix/endian_little.go +9 -0
  729. data/go/vendor/golang.org/x/sys/unix/env_unix.go +31 -0
  730. data/go/vendor/golang.org/x/sys/unix/fcntl.go +36 -0
  731. data/go/vendor/golang.org/x/sys/unix/fcntl_darwin.go +24 -0
  732. data/go/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go +13 -0
  733. data/go/vendor/golang.org/x/sys/unix/fdset.go +27 -0
  734. data/go/vendor/golang.org/x/sys/unix/gccgo.go +59 -0
  735. data/go/vendor/golang.org/x/sys/unix/gccgo_c.c +44 -0
  736. data/go/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go +20 -0
  737. data/go/vendor/golang.org/x/sys/unix/ifreq_linux.go +139 -0
  738. data/go/vendor/golang.org/x/sys/unix/ioctl_linux.go +334 -0
  739. data/go/vendor/golang.org/x/sys/unix/ioctl_signed.go +74 -0
  740. data/go/vendor/golang.org/x/sys/unix/ioctl_unsigned.go +74 -0
  741. data/go/vendor/golang.org/x/sys/unix/ioctl_zos.go +71 -0
  742. data/go/vendor/golang.org/x/sys/unix/mkall.sh +250 -0
  743. data/go/vendor/golang.org/x/sys/unix/mkerrors.sh +814 -0
  744. data/go/vendor/golang.org/x/sys/unix/mmap_nomremap.go +13 -0
  745. data/go/vendor/golang.org/x/sys/unix/mremap.go +57 -0
  746. data/go/vendor/golang.org/x/sys/unix/pagesize_unix.go +15 -0
  747. data/go/vendor/golang.org/x/sys/unix/pledge_openbsd.go +111 -0
  748. data/go/vendor/golang.org/x/sys/unix/ptrace_darwin.go +11 -0
  749. data/go/vendor/golang.org/x/sys/unix/ptrace_ios.go +11 -0
  750. data/go/vendor/golang.org/x/sys/unix/race.go +30 -0
  751. data/go/vendor/golang.org/x/sys/unix/race0.go +25 -0
  752. data/go/vendor/golang.org/x/sys/unix/readdirent_getdents.go +12 -0
  753. data/go/vendor/golang.org/x/sys/unix/readdirent_getdirentries.go +19 -0
  754. data/go/vendor/golang.org/x/sys/unix/readv_unix.go +103 -0
  755. data/go/vendor/golang.org/x/sys/unix/sockcmsg_dragonfly.go +16 -0
  756. data/go/vendor/golang.org/x/sys/unix/sockcmsg_linux.go +85 -0
  757. data/go/vendor/golang.org/x/sys/unix/sockcmsg_unix.go +106 -0
  758. data/go/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go +46 -0
  759. data/go/vendor/golang.org/x/sys/unix/sockcmsg_zos.go +58 -0
  760. data/go/vendor/golang.org/x/sys/unix/symaddr_zos_s390x.s +75 -0
  761. data/go/vendor/golang.org/x/sys/unix/syscall.go +86 -0
  762. data/go/vendor/golang.org/x/sys/unix/syscall_aix.go +582 -0
  763. data/go/vendor/golang.org/x/sys/unix/syscall_aix_ppc.go +52 -0
  764. data/go/vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go +83 -0
  765. data/go/vendor/golang.org/x/sys/unix/syscall_bsd.go +609 -0
  766. data/go/vendor/golang.org/x/sys/unix/syscall_darwin.go +711 -0
  767. data/go/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go +50 -0
  768. data/go/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go +50 -0
  769. data/go/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go +26 -0
  770. data/go/vendor/golang.org/x/sys/unix/syscall_dragonfly.go +359 -0
  771. data/go/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go +56 -0
  772. data/go/vendor/golang.org/x/sys/unix/syscall_freebsd.go +455 -0
  773. data/go/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go +64 -0
  774. data/go/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go +64 -0
  775. data/go/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go +60 -0
  776. data/go/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go +60 -0
  777. data/go/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go +60 -0
  778. data/go/vendor/golang.org/x/sys/unix/syscall_hurd.go +30 -0
  779. data/go/vendor/golang.org/x/sys/unix/syscall_hurd_386.go +28 -0
  780. data/go/vendor/golang.org/x/sys/unix/syscall_illumos.go +78 -0
  781. data/go/vendor/golang.org/x/sys/unix/syscall_linux.go +2574 -0
  782. data/go/vendor/golang.org/x/sys/unix/syscall_linux_386.go +313 -0
  783. data/go/vendor/golang.org/x/sys/unix/syscall_linux_alarm.go +12 -0
  784. data/go/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go +144 -0
  785. data/go/vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go +12 -0
  786. data/go/vendor/golang.org/x/sys/unix/syscall_linux_arm.go +218 -0
  787. data/go/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go +188 -0
  788. data/go/vendor/golang.org/x/sys/unix/syscall_linux_gc.go +14 -0
  789. data/go/vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go +16 -0
  790. data/go/vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go +13 -0
  791. data/go/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go +30 -0
  792. data/go/vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go +20 -0
  793. data/go/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go +220 -0
  794. data/go/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go +187 -0
  795. data/go/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go +173 -0
  796. data/go/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go +203 -0
  797. data/go/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go +114 -0
  798. data/go/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go +193 -0
  799. data/go/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go +295 -0
  800. data/go/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go +111 -0
  801. data/go/vendor/golang.org/x/sys/unix/syscall_netbsd.go +388 -0
  802. data/go/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go +37 -0
  803. data/go/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go +37 -0
  804. data/go/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go +37 -0
  805. data/go/vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go +37 -0
  806. data/go/vendor/golang.org/x/sys/unix/syscall_openbsd.go +346 -0
  807. data/go/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go +41 -0
  808. data/go/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go +41 -0
  809. data/go/vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go +41 -0
  810. data/go/vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go +41 -0
  811. data/go/vendor/golang.org/x/sys/unix/syscall_openbsd_libc.go +26 -0
  812. data/go/vendor/golang.org/x/sys/unix/syscall_openbsd_mips64.go +39 -0
  813. data/go/vendor/golang.org/x/sys/unix/syscall_openbsd_ppc64.go +41 -0
  814. data/go/vendor/golang.org/x/sys/unix/syscall_openbsd_riscv64.go +41 -0
  815. data/go/vendor/golang.org/x/sys/unix/syscall_solaris.go +1183 -0
  816. data/go/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go +27 -0
  817. data/go/vendor/golang.org/x/sys/unix/syscall_unix.go +619 -0
  818. data/go/vendor/golang.org/x/sys/unix/syscall_unix_gc.go +14 -0
  819. data/go/vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go +22 -0
  820. data/go/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go +3213 -0
  821. data/go/vendor/golang.org/x/sys/unix/sysvshm_linux.go +20 -0
  822. data/go/vendor/golang.org/x/sys/unix/sysvshm_unix.go +51 -0
  823. data/go/vendor/golang.org/x/sys/unix/sysvshm_unix_other.go +13 -0
  824. data/go/vendor/golang.org/x/sys/unix/timestruct.go +76 -0
  825. data/go/vendor/golang.org/x/sys/unix/unveil_openbsd.go +51 -0
  826. data/go/vendor/golang.org/x/sys/unix/vgetrandom_linux.go +13 -0
  827. data/go/vendor/golang.org/x/sys/unix/vgetrandom_unsupported.go +11 -0
  828. data/go/vendor/golang.org/x/sys/unix/xattr_bsd.go +280 -0
  829. data/go/vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go +1384 -0
  830. data/go/vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go +1385 -0
  831. data/go/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +1922 -0
  832. data/go/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +1922 -0
  833. data/go/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go +1737 -0
  834. data/go/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go +2042 -0
  835. data/go/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go +2039 -0
  836. data/go/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go +2033 -0
  837. data/go/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm64.go +2033 -0
  838. data/go/vendor/golang.org/x/sys/unix/zerrors_freebsd_riscv64.go +2147 -0
  839. data/go/vendor/golang.org/x/sys/unix/zerrors_linux.go +4207 -0
  840. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +883 -0
  841. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +883 -0
  842. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +888 -0
  843. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +885 -0
  844. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +875 -0
  845. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +889 -0
  846. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +889 -0
  847. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +889 -0
  848. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +889 -0
  849. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +941 -0
  850. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +945 -0
  851. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +945 -0
  852. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +885 -0
  853. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +944 -0
  854. data/go/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +987 -0
  855. data/go/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go +1779 -0
  856. data/go/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go +1769 -0
  857. data/go/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go +1758 -0
  858. data/go/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm64.go +1769 -0
  859. data/go/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go +1905 -0
  860. data/go/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go +1905 -0
  861. data/go/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go +1905 -0
  862. data/go/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm64.go +1905 -0
  863. data/go/vendor/golang.org/x/sys/unix/zerrors_openbsd_mips64.go +1905 -0
  864. data/go/vendor/golang.org/x/sys/unix/zerrors_openbsd_ppc64.go +1904 -0
  865. data/go/vendor/golang.org/x/sys/unix/zerrors_openbsd_riscv64.go +1903 -0
  866. data/go/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go +1556 -0
  867. data/go/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go +990 -0
  868. data/go/vendor/golang.org/x/sys/unix/zptrace_armnn_linux.go +40 -0
  869. data/go/vendor/golang.org/x/sys/unix/zptrace_linux_arm64.go +17 -0
  870. data/go/vendor/golang.org/x/sys/unix/zptrace_mipsnn_linux.go +49 -0
  871. data/go/vendor/golang.org/x/sys/unix/zptrace_mipsnnle_linux.go +49 -0
  872. data/go/vendor/golang.org/x/sys/unix/zptrace_x86_linux.go +79 -0
  873. data/go/vendor/golang.org/x/sys/unix/zsymaddr_zos_s390x.s +364 -0
  874. data/go/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go +1461 -0
  875. data/go/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go +1420 -0
  876. data/go/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go +1188 -0
  877. data/go/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go +1069 -0
  878. data/go/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +2728 -0
  879. data/go/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +799 -0
  880. data/go/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +2728 -0
  881. data/go/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +799 -0
  882. data/go/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go +1666 -0
  883. data/go/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go +1886 -0
  884. data/go/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +1886 -0
  885. data/go/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +1886 -0
  886. data/go/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go +1886 -0
  887. data/go/vendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go +1886 -0
  888. data/go/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go +101 -0
  889. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux.go +2267 -0
  890. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go +469 -0
  891. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +636 -0
  892. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go +584 -0
  893. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go +535 -0
  894. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go +469 -0
  895. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go +636 -0
  896. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go +630 -0
  897. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go +619 -0
  898. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go +636 -0
  899. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go +641 -0
  900. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +687 -0
  901. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +687 -0
  902. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go +531 -0
  903. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +478 -0
  904. data/go/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +631 -0
  905. data/go/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +1848 -0
  906. data/go/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +1848 -0
  907. data/go/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +1848 -0
  908. data/go/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go +1848 -0
  909. data/go/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +2407 -0
  910. data/go/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +719 -0
  911. data/go/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +2407 -0
  912. data/go/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +719 -0
  913. data/go/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +2407 -0
  914. data/go/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +719 -0
  915. data/go/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +2407 -0
  916. data/go/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +719 -0
  917. data/go/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +2407 -0
  918. data/go/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +719 -0
  919. data/go/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +2407 -0
  920. data/go/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +862 -0
  921. data/go/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +2407 -0
  922. data/go/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +719 -0
  923. data/go/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +2217 -0
  924. data/go/vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go +3458 -0
  925. data/go/vendor/golang.org/x/sys/unix/zsysctl_openbsd_386.go +280 -0
  926. data/go/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go +280 -0
  927. data/go/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm.go +280 -0
  928. data/go/vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm64.go +280 -0
  929. data/go/vendor/golang.org/x/sys/unix/zsysctl_openbsd_mips64.go +280 -0
  930. data/go/vendor/golang.org/x/sys/unix/zsysctl_openbsd_ppc64.go +280 -0
  931. data/go/vendor/golang.org/x/sys/unix/zsysctl_openbsd_riscv64.go +281 -0
  932. data/go/vendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go +439 -0
  933. data/go/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go +437 -0
  934. data/go/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go +316 -0
  935. data/go/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go +393 -0
  936. data/go/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go +393 -0
  937. data/go/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go +393 -0
  938. data/go/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm64.go +393 -0
  939. data/go/vendor/golang.org/x/sys/unix/zsysnum_freebsd_riscv64.go +393 -0
  940. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +470 -0
  941. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +394 -0
  942. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +434 -0
  943. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +337 -0
  944. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +334 -0
  945. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +454 -0
  946. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +384 -0
  947. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +384 -0
  948. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +454 -0
  949. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +461 -0
  950. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +433 -0
  951. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +433 -0
  952. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +338 -0
  953. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +399 -0
  954. data/go/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +413 -0
  955. data/go/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go +274 -0
  956. data/go/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go +274 -0
  957. data/go/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go +274 -0
  958. data/go/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm64.go +274 -0
  959. data/go/vendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go +219 -0
  960. data/go/vendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go +219 -0
  961. data/go/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go +219 -0
  962. data/go/vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm64.go +218 -0
  963. data/go/vendor/golang.org/x/sys/unix/zsysnum_openbsd_mips64.go +221 -0
  964. data/go/vendor/golang.org/x/sys/unix/zsysnum_openbsd_ppc64.go +217 -0
  965. data/go/vendor/golang.org/x/sys/unix/zsysnum_openbsd_riscv64.go +218 -0
  966. data/go/vendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go +2852 -0
  967. data/go/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go +353 -0
  968. data/go/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go +357 -0
  969. data/go/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +878 -0
  970. data/go/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +878 -0
  971. data/go/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go +473 -0
  972. data/go/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +651 -0
  973. data/go/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +656 -0
  974. data/go/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +642 -0
  975. data/go/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go +636 -0
  976. data/go/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go +638 -0
  977. data/go/vendor/golang.org/x/sys/unix/ztypes_linux.go +6475 -0
  978. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +717 -0
  979. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +731 -0
  980. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +711 -0
  981. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +710 -0
  982. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go +711 -0
  983. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +716 -0
  984. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +713 -0
  985. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +713 -0
  986. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +716 -0
  987. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +724 -0
  988. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +719 -0
  989. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +719 -0
  990. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +798 -0
  991. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +733 -0
  992. data/go/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +714 -0
  993. data/go/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go +585 -0
  994. data/go/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go +593 -0
  995. data/go/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go +590 -0
  996. data/go/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm64.go +593 -0
  997. data/go/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go +568 -0
  998. data/go/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go +568 -0
  999. data/go/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go +575 -0
  1000. data/go/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go +568 -0
  1001. data/go/vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go +568 -0
  1002. data/go/vendor/golang.org/x/sys/unix/ztypes_openbsd_ppc64.go +570 -0
  1003. data/go/vendor/golang.org/x/sys/unix/ztypes_openbsd_riscv64.go +570 -0
  1004. data/go/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go +516 -0
  1005. data/go/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go +552 -0
  1006. data/go/vendor/golang.org/x/sys/windows/aliases.go +13 -0
  1007. data/go/vendor/golang.org/x/sys/windows/dll_windows.go +380 -0
  1008. data/go/vendor/golang.org/x/sys/windows/env_windows.go +57 -0
  1009. data/go/vendor/golang.org/x/sys/windows/eventlog.go +20 -0
  1010. data/go/vendor/golang.org/x/sys/windows/exec_windows.go +248 -0
  1011. data/go/vendor/golang.org/x/sys/windows/memory_windows.go +48 -0
  1012. data/go/vendor/golang.org/x/sys/windows/mkerrors.bash +70 -0
  1013. data/go/vendor/golang.org/x/sys/windows/mkknownfolderids.bash +27 -0
  1014. data/go/vendor/golang.org/x/sys/windows/mksyscall.go +9 -0
  1015. data/go/vendor/golang.org/x/sys/windows/race.go +30 -0
  1016. data/go/vendor/golang.org/x/sys/windows/race0.go +25 -0
  1017. data/go/vendor/golang.org/x/sys/windows/security_windows.go +1537 -0
  1018. data/go/vendor/golang.org/x/sys/windows/service.go +257 -0
  1019. data/go/vendor/golang.org/x/sys/windows/setupapi_windows.go +1425 -0
  1020. data/go/vendor/golang.org/x/sys/windows/str.go +22 -0
  1021. data/go/vendor/golang.org/x/sys/windows/syscall.go +104 -0
  1022. data/go/vendor/golang.org/x/sys/windows/syscall_windows.go +1952 -0
  1023. data/go/vendor/golang.org/x/sys/windows/types_windows.go +4057 -0
  1024. data/go/vendor/golang.org/x/sys/windows/types_windows_386.go +35 -0
  1025. data/go/vendor/golang.org/x/sys/windows/types_windows_amd64.go +34 -0
  1026. data/go/vendor/golang.org/x/sys/windows/types_windows_arm.go +35 -0
  1027. data/go/vendor/golang.org/x/sys/windows/types_windows_arm64.go +34 -0
  1028. data/go/vendor/golang.org/x/sys/windows/zerrors_windows.go +9468 -0
  1029. data/go/vendor/golang.org/x/sys/windows/zknownfolderids_windows.go +149 -0
  1030. data/go/vendor/golang.org/x/sys/windows/zsyscall_windows.go +4828 -0
  1031. data/go/vendor/golang.org/x/text/LICENSE +27 -0
  1032. data/go/vendor/golang.org/x/text/PATENTS +22 -0
  1033. data/go/vendor/golang.org/x/text/secure/bidirule/bidirule.go +340 -0
  1034. data/go/vendor/golang.org/x/text/transform/transform.go +709 -0
  1035. data/go/vendor/golang.org/x/text/unicode/bidi/bidi.go +359 -0
  1036. data/go/vendor/golang.org/x/text/unicode/bidi/bracket.go +335 -0
  1037. data/go/vendor/golang.org/x/text/unicode/bidi/core.go +1064 -0
  1038. data/go/vendor/golang.org/x/text/unicode/bidi/prop.go +206 -0
  1039. data/go/vendor/golang.org/x/text/unicode/bidi/tables15.0.0.go +2042 -0
  1040. data/go/vendor/golang.org/x/text/unicode/bidi/tables17.0.0.go +2135 -0
  1041. data/go/vendor/golang.org/x/text/unicode/bidi/trieval.go +48 -0
  1042. data/go/vendor/golang.org/x/text/unicode/norm/composition.go +512 -0
  1043. data/go/vendor/golang.org/x/text/unicode/norm/forminfo.go +296 -0
  1044. data/go/vendor/golang.org/x/text/unicode/norm/input.go +109 -0
  1045. data/go/vendor/golang.org/x/text/unicode/norm/iter.go +454 -0
  1046. data/go/vendor/golang.org/x/text/unicode/norm/normalize.go +610 -0
  1047. data/go/vendor/golang.org/x/text/unicode/norm/readwriter.go +125 -0
  1048. data/go/vendor/golang.org/x/text/unicode/norm/tables15.0.0.go +7907 -0
  1049. data/go/vendor/golang.org/x/text/unicode/norm/tables17.0.0.go +8104 -0
  1050. data/go/vendor/golang.org/x/text/unicode/norm/transform.go +88 -0
  1051. data/go/vendor/golang.org/x/text/unicode/norm/trie.go +54 -0
  1052. data/go/vendor/modules.txt +63 -0
  1053. data/lib/puma_plus/core/version.rb +13 -0
  1054. data/lib/puma_plus/core.rb +60 -0
  1055. metadata +1099 -0
@@ -0,0 +1,3036 @@
1
+ // Copyright 2015 The Go Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ //go:build !(go1.27 && !http2legacy)
6
+
7
+ // Transport code.
8
+
9
+ package http2
10
+
11
+ import (
12
+ "bufio"
13
+ "bytes"
14
+ "compress/flate"
15
+ "compress/gzip"
16
+ "context"
17
+ "crypto/rand"
18
+ "crypto/tls"
19
+ "errors"
20
+ "fmt"
21
+ "io"
22
+ "io/fs"
23
+ "log"
24
+ "math"
25
+ "math/bits"
26
+ "net"
27
+ "net/http"
28
+ "net/http/httptrace"
29
+ "net/textproto"
30
+ "strconv"
31
+ "sync"
32
+ "sync/atomic"
33
+ "time"
34
+
35
+ "golang.org/x/net/http/httpguts"
36
+ "golang.org/x/net/http2/hpack"
37
+ "golang.org/x/net/internal/httpcommon"
38
+ )
39
+
40
+ const (
41
+ // transportDefaultConnFlow is how many connection-level flow control
42
+ // tokens we give the server at start-up, past the default 64k.
43
+ transportDefaultConnFlow = 1 << 30
44
+
45
+ // transportDefaultStreamFlow is how many stream-level flow
46
+ // control tokens we announce to the peer, and how many bytes
47
+ // we buffer per stream.
48
+ transportDefaultStreamFlow = 4 << 20
49
+
50
+ defaultUserAgent = "Go-http-client/2.0"
51
+
52
+ // initialMaxConcurrentStreams is a connections maxConcurrentStreams until
53
+ // it's received servers initial SETTINGS frame, which corresponds with the
54
+ // spec's minimum recommended value.
55
+ initialMaxConcurrentStreams = 100
56
+
57
+ // defaultMaxConcurrentStreams is a connections default maxConcurrentStreams
58
+ // if the server doesn't include one in its initial SETTINGS frame.
59
+ defaultMaxConcurrentStreams = 1000
60
+ )
61
+
62
+ type transportInternal struct {
63
+ // t1, if non-nil, is the standard library Transport using
64
+ // this transport. Its settings are used (but not its
65
+ // RoundTrip method, etc).
66
+ t1 *http.Transport
67
+
68
+ connPoolOnce sync.Once
69
+ connPoolOrDef ClientConnPool // non-nil version of ConnPool
70
+
71
+ *transportTestHooks
72
+ }
73
+
74
+ // Hook points used for testing.
75
+ // Outside of tests, t.transportTestHooks is nil and these all have minimal implementations.
76
+ // Inside tests, see the testSyncHooks function docs.
77
+
78
+ type transportTestHooks struct {
79
+ newclientconn func(*ClientConn)
80
+ }
81
+
82
+ func (t *Transport) maxHeaderListSize() uint32 {
83
+ n := int64(t.MaxHeaderListSize)
84
+ if t.t1 != nil && t.t1.MaxResponseHeaderBytes != 0 {
85
+ n = t.t1.MaxResponseHeaderBytes
86
+ if n > 0 {
87
+ n = adjustHTTP1MaxHeaderSize(n)
88
+ }
89
+ }
90
+ if n <= 0 {
91
+ return 10 << 20
92
+ }
93
+ if n >= 0xffffffff {
94
+ return 0
95
+ }
96
+ return uint32(n)
97
+ }
98
+
99
+ func (t *Transport) disableCompression() bool {
100
+ return t.DisableCompression || (t.t1 != nil && t.t1.DisableCompression)
101
+ }
102
+
103
+ func configureTransport(t1 *http.Transport) error {
104
+ _, err := configureTransports(t1)
105
+ return err
106
+ }
107
+
108
+ func configureTransports(t1 *http.Transport) (*Transport, error) {
109
+ connPool := new(clientConnPool)
110
+ t2 := &Transport{
111
+ ConnPool: noDialClientConnPool{connPool},
112
+ transportInternal: transportInternal{
113
+ t1: t1,
114
+ },
115
+ }
116
+ connPool.t = t2
117
+ if err := registerHTTPSProtocol(t1, noDialH2RoundTripper{t2}); err != nil {
118
+ return nil, err
119
+ }
120
+ if t1.TLSClientConfig == nil {
121
+ t1.TLSClientConfig = new(tls.Config)
122
+ }
123
+ if !strSliceContains(t1.TLSClientConfig.NextProtos, "h2") {
124
+ t1.TLSClientConfig.NextProtos = append([]string{"h2"}, t1.TLSClientConfig.NextProtos...)
125
+ }
126
+ if !strSliceContains(t1.TLSClientConfig.NextProtos, "http/1.1") {
127
+ t1.TLSClientConfig.NextProtos = append(t1.TLSClientConfig.NextProtos, "http/1.1")
128
+ }
129
+ upgradeFn := func(scheme, authority string, c net.Conn) http.RoundTripper {
130
+ addr := authorityAddr(scheme, authority)
131
+ if used, err := connPool.addConnIfNeeded(addr, t2, c); err != nil {
132
+ go c.Close()
133
+ return erringRoundTripper{err}
134
+ } else if !used {
135
+ // Turns out we don't need this c.
136
+ // For example, two goroutines made requests to the same host
137
+ // at the same time, both kicking off TCP dials. (since protocol
138
+ // was unknown)
139
+ go c.Close()
140
+ }
141
+ if scheme == "http" {
142
+ return (*unencryptedTransport)(t2)
143
+ }
144
+ return t2
145
+ }
146
+ if t1.TLSNextProto == nil {
147
+ t1.TLSNextProto = make(map[string]func(string, *tls.Conn) http.RoundTripper)
148
+ }
149
+ t1.TLSNextProto[NextProtoTLS] = func(authority string, c *tls.Conn) http.RoundTripper {
150
+ return upgradeFn("https", authority, c)
151
+ }
152
+ // The "unencrypted_http2" TLSNextProto key is used to pass off non-TLS HTTP/2 conns.
153
+ t1.TLSNextProto[nextProtoUnencryptedHTTP2] = func(authority string, c *tls.Conn) http.RoundTripper {
154
+ nc, err := unencryptedNetConnFromTLSConn(c)
155
+ if err != nil {
156
+ go c.Close()
157
+ return erringRoundTripper{err}
158
+ }
159
+ return upgradeFn("http", authority, nc)
160
+ }
161
+ return t2, nil
162
+ }
163
+
164
+ // unencryptedTransport is a Transport with a RoundTrip method that
165
+ // always permits http:// URLs.
166
+ type unencryptedTransport Transport
167
+
168
+ func (t *unencryptedTransport) RoundTrip(req *http.Request) (*http.Response, error) {
169
+ return (*Transport)(t).RoundTripOpt(req, RoundTripOpt{allowHTTP: true})
170
+ }
171
+
172
+ func (t *Transport) connPool() ClientConnPool {
173
+ t.connPoolOnce.Do(t.initConnPool)
174
+ return t.connPoolOrDef
175
+ }
176
+
177
+ func (t *Transport) initConnPool() {
178
+ if t.ConnPool != nil {
179
+ t.connPoolOrDef = t.ConnPool
180
+ } else {
181
+ t.connPoolOrDef = &clientConnPool{t: t}
182
+ }
183
+ }
184
+
185
+ // ClientConn is the state of a single HTTP/2 client connection to an
186
+ // HTTP/2 server.
187
+ type ClientConn struct {
188
+ t *Transport
189
+ tconn net.Conn // usually *tls.Conn, except specialized impls
190
+ tlsState *tls.ConnectionState // nil only for specialized impls
191
+ atomicReused uint32 // whether conn is being reused; atomic
192
+ singleUse bool // whether being used for a single http.Request
193
+ getConnCalled bool // used by clientConnPool
194
+
195
+ // readLoop goroutine fields:
196
+ readerDone chan struct{} // closed on error
197
+ readerErr error // set before readerDone is closed
198
+
199
+ idleTimeout time.Duration // or 0 for never
200
+ idleTimer *time.Timer
201
+
202
+ mu sync.Mutex // guards following
203
+ cond *sync.Cond // hold mu; broadcast on flow/closed changes
204
+ flow outflow // our conn-level flow control quota (cs.outflow is per stream)
205
+ inflow inflow // peer's conn-level flow control
206
+ doNotReuse bool // whether conn is marked to not be reused for any future requests
207
+ closing bool
208
+ closed bool
209
+ closedOnIdle bool // true if conn was closed for idleness
210
+ seenSettings bool // true if we've seen a settings frame, false otherwise
211
+ seenSettingsChan chan struct{} // closed when seenSettings is true or frame reading fails
212
+ wantSettingsAck bool // we sent a SETTINGS frame and haven't heard back
213
+ goAway *GoAwayFrame // if non-nil, the GoAwayFrame we received
214
+ goAwayDebug string // goAway frame's debug data, retained as a string
215
+ streams map[uint32]*clientStream // client-initiated
216
+ streamsReserved int // incr by ReserveNewRequest; decr on RoundTrip
217
+ nextStreamID uint32
218
+ pendingRequests int // requests blocked and waiting to be sent because len(streams) == maxConcurrentStreams
219
+ pings map[[8]byte]chan struct{} // in flight ping data to notification channel
220
+ br *bufio.Reader
221
+ lastActive time.Time
222
+ lastIdle time.Time // time last idle
223
+ // Settings from peer: (also guarded by wmu)
224
+ maxFrameSize uint32
225
+ maxConcurrentStreams uint32
226
+ peerMaxHeaderListSize uint64
227
+ peerMaxHeaderTableSize uint32
228
+ initialWindowSize uint32
229
+ initialStreamRecvWindowSize int32
230
+ readIdleTimeout time.Duration
231
+ pingTimeout time.Duration
232
+ extendedConnectAllowed bool
233
+ strictMaxConcurrentStreams bool
234
+
235
+ // rstStreamPingsBlocked works around an unfortunate gRPC behavior.
236
+ // gRPC strictly limits the number of PING frames that it will receive.
237
+ // The default is two pings per two hours, but the limit resets every time
238
+ // the gRPC endpoint sends a HEADERS or DATA frame. See golang/go#70575.
239
+ //
240
+ // rstStreamPingsBlocked is set after receiving a response to a PING frame
241
+ // bundled with an RST_STREAM (see pendingResets below), and cleared after
242
+ // receiving a HEADERS or DATA frame.
243
+ rstStreamPingsBlocked bool
244
+
245
+ // pendingResets is the number of RST_STREAM frames we have sent to the peer,
246
+ // without confirming that the peer has received them. When we send a RST_STREAM,
247
+ // we bundle it with a PING frame, unless a PING is already in flight. We count
248
+ // the reset stream against the connection's concurrency limit until we get
249
+ // a PING response. This limits the number of requests we'll try to send to a
250
+ // completely unresponsive connection.
251
+ pendingResets int
252
+
253
+ // readBeforeStreamID is the smallest stream ID that has not been followed by
254
+ // a frame read from the peer. We use this to determine when a request may
255
+ // have been sent to a completely unresponsive connection:
256
+ // If the request ID is less than readBeforeStreamID, then we have had some
257
+ // indication of life on the connection since sending the request.
258
+ readBeforeStreamID uint32
259
+
260
+ // reqHeaderMu is a 1-element semaphore channel controlling access to sending new requests.
261
+ // Write to reqHeaderMu to lock it, read from it to unlock.
262
+ // Lock reqmu BEFORE mu or wmu.
263
+ reqHeaderMu chan struct{}
264
+
265
+ // internalStateHook reports state changes back to the net/http.ClientConn.
266
+ // Note that this is different from the user state hook registered by
267
+ // net/http.ClientConn.SetStateHook: The internal hook calls ClientConn,
268
+ // which calls the user hook.
269
+ internalStateHook func()
270
+
271
+ // wmu is held while writing.
272
+ // Acquire BEFORE mu when holding both, to avoid blocking mu on network writes.
273
+ // Only acquire both at the same time when changing peer settings.
274
+ wmu sync.Mutex
275
+ bw *bufio.Writer
276
+ fr *Framer
277
+ werr error // first write error that has occurred
278
+ hbuf bytes.Buffer // HPACK encoder writes into this
279
+ henc *hpack.Encoder
280
+ }
281
+
282
+ // clientStream is the state for a single HTTP/2 stream. One of these
283
+ // is created for each Transport.RoundTrip call.
284
+ type clientStream struct {
285
+ cc *ClientConn
286
+
287
+ // Fields of Request that we may access even after the response body is closed.
288
+ ctx context.Context
289
+ reqCancel <-chan struct{}
290
+
291
+ trace *httptrace.ClientTrace // or nil
292
+ ID uint32
293
+ bufPipe pipe // buffered pipe with the flow-controlled response payload
294
+ requestedGzip bool
295
+ isHead bool
296
+
297
+ abortOnce sync.Once
298
+ abort chan struct{} // closed to signal stream should end immediately
299
+ abortErr error // set if abort is closed
300
+
301
+ peerClosed chan struct{} // closed when the peer sends an END_STREAM flag
302
+ donec chan struct{} // closed after the stream is in the closed state
303
+ on100 chan struct{} // buffered; written to if a 100 is received
304
+
305
+ respHeaderRecv chan struct{} // closed when headers are received
306
+ res *http.Response // set if respHeaderRecv is closed
307
+
308
+ flow outflow // guarded by cc.mu
309
+ inflow inflow // guarded by cc.mu
310
+ bytesRemain int64 // -1 means unknown; owned by transportResponseBody.Read
311
+ readErr error // sticky read error; owned by transportResponseBody.Read
312
+
313
+ reqBody io.ReadCloser
314
+ reqBodyContentLength int64 // -1 means unknown
315
+ reqBodyClosed chan struct{} // guarded by cc.mu; non-nil on Close, closed when done
316
+
317
+ // owned by writeRequest:
318
+ sentEndStream bool // sent an END_STREAM flag to the peer
319
+ sentHeaders bool
320
+
321
+ // owned by clientConnReadLoop:
322
+ firstByte bool // got the first response byte
323
+ pastHeaders bool // got first MetaHeadersFrame (actual headers)
324
+ pastTrailers bool // got optional second MetaHeadersFrame (trailers)
325
+ readClosed bool // peer sent an END_STREAM flag
326
+ readAborted bool // read loop reset the stream
327
+ totalHeaderSize int64 // total size of 1xx headers seen
328
+
329
+ trailer http.Header // accumulated trailers
330
+ resTrailer *http.Header // client's Response.Trailer
331
+ }
332
+
333
+ var got1xxFuncForTests func(int, textproto.MIMEHeader) error
334
+
335
+ // get1xxTraceFunc returns the value of request's httptrace.ClientTrace.Got1xxResponse func,
336
+ // if any. It returns nil if not set or if the Go version is too old.
337
+ func (cs *clientStream) get1xxTraceFunc() func(int, textproto.MIMEHeader) error {
338
+ if fn := got1xxFuncForTests; fn != nil {
339
+ return fn
340
+ }
341
+ return traceGot1xxResponseFunc(cs.trace)
342
+ }
343
+
344
+ func (cs *clientStream) abortStream(err error) {
345
+ cs.cc.mu.Lock()
346
+ defer cs.cc.mu.Unlock()
347
+ cs.abortStreamLocked(err)
348
+ }
349
+
350
+ func (cs *clientStream) abortStreamLocked(err error) {
351
+ cs.abortOnce.Do(func() {
352
+ cs.abortErr = err
353
+ close(cs.abort)
354
+ })
355
+ if cs.reqBody != nil {
356
+ cs.closeReqBodyLocked()
357
+ }
358
+ // TODO(dneil): Clean up tests where cs.cc.cond is nil.
359
+ if cs.cc.cond != nil {
360
+ // Wake up writeRequestBody if it is waiting on flow control.
361
+ cs.cc.cond.Broadcast()
362
+ }
363
+ }
364
+
365
+ func (cs *clientStream) abortRequestBodyWrite() {
366
+ cc := cs.cc
367
+ cc.mu.Lock()
368
+ defer cc.mu.Unlock()
369
+ if cs.reqBody != nil && cs.reqBodyClosed == nil {
370
+ cs.closeReqBodyLocked()
371
+ cc.cond.Broadcast()
372
+ }
373
+ }
374
+
375
+ func (cs *clientStream) closeReqBodyLocked() {
376
+ if cs.reqBodyClosed != nil {
377
+ return
378
+ }
379
+ cs.reqBodyClosed = make(chan struct{})
380
+ reqBodyClosed := cs.reqBodyClosed
381
+ go func() {
382
+ cs.reqBody.Close()
383
+ close(reqBodyClosed)
384
+ }()
385
+ }
386
+
387
+ type stickyErrWriter struct {
388
+ conn net.Conn
389
+ timeout time.Duration
390
+ err *error
391
+ }
392
+
393
+ func (sew stickyErrWriter) Write(p []byte) (n int, err error) {
394
+ if *sew.err != nil {
395
+ return 0, *sew.err
396
+ }
397
+ n, err = writeWithByteTimeout(sew.conn, sew.timeout, p)
398
+ *sew.err = err
399
+ return n, err
400
+ }
401
+
402
+ func (t *Transport) roundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error) {
403
+ switch req.URL.Scheme {
404
+ case "https":
405
+ // Always okay.
406
+ case "http":
407
+ if !t.AllowHTTP && !opt.allowHTTP {
408
+ return nil, errors.New("http2: unencrypted HTTP/2 not enabled")
409
+ }
410
+ default:
411
+ return nil, errors.New("http2: unsupported scheme")
412
+ }
413
+ return t.roundTripViaPool(req, opt, t.connPool())
414
+ }
415
+
416
+ func (t *Transport) closeIdleConnections() {
417
+ if cp, ok := t.connPool().(clientConnPoolIdleCloser); ok {
418
+ cp.closeIdleConnections()
419
+ }
420
+ }
421
+
422
+ func (t *Transport) dialClientConn(ctx context.Context, addr string, singleUse bool) (*ClientConn, error) {
423
+ host, _, err := net.SplitHostPort(addr)
424
+ if err != nil {
425
+ return nil, err
426
+ }
427
+ tconn, err := t.dialTLS(ctx, "tcp", addr, t.newTLSConfig(host))
428
+ if err != nil {
429
+ return nil, err
430
+ }
431
+ return t.newClientConn(tconn, singleUse, nil)
432
+ }
433
+
434
+ func (t *Transport) newTLSConfig(host string) *tls.Config {
435
+ cfg := new(tls.Config)
436
+ if t.TLSClientConfig != nil {
437
+ *cfg = *t.TLSClientConfig.Clone()
438
+ }
439
+ if !strSliceContains(cfg.NextProtos, NextProtoTLS) {
440
+ cfg.NextProtos = append([]string{NextProtoTLS}, cfg.NextProtos...)
441
+ }
442
+ if cfg.ServerName == "" {
443
+ cfg.ServerName = host
444
+ }
445
+ return cfg
446
+ }
447
+
448
+ // disableKeepAlives reports whether connections should be closed as
449
+ // soon as possible after handling the first request.
450
+ func (t *Transport) disableKeepAlives() bool {
451
+ return t.t1 != nil && t.t1.DisableKeepAlives
452
+ }
453
+
454
+ func (t *Transport) expectContinueTimeout() time.Duration {
455
+ if t.t1 == nil {
456
+ return 0
457
+ }
458
+ return t.t1.ExpectContinueTimeout
459
+ }
460
+
461
+ func (t *Transport) newUserClientConn(c net.Conn) (*ClientConn, error) {
462
+ return t.newClientConn(c, t.disableKeepAlives(), nil)
463
+ }
464
+
465
+ func (t *Transport) newClientConn(c net.Conn, singleUse bool, internalStateHook func()) (*ClientConn, error) {
466
+ conf := configFromTransport(t)
467
+ cc := &ClientConn{
468
+ t: t,
469
+ tconn: c,
470
+ readerDone: make(chan struct{}),
471
+ nextStreamID: 1,
472
+ maxFrameSize: 16 << 10, // spec default
473
+ initialWindowSize: 65535, // spec default
474
+ initialStreamRecvWindowSize: conf.MaxUploadBufferPerStream,
475
+ maxConcurrentStreams: initialMaxConcurrentStreams, // "infinite", per spec. Use a smaller value until we have received server settings.
476
+ strictMaxConcurrentStreams: conf.StrictMaxConcurrentRequests,
477
+ peerMaxHeaderListSize: 0xffffffffffffffff, // "infinite", per spec. Use 2^64-1 instead.
478
+ streams: make(map[uint32]*clientStream),
479
+ singleUse: singleUse,
480
+ seenSettingsChan: make(chan struct{}),
481
+ wantSettingsAck: true,
482
+ readIdleTimeout: conf.SendPingTimeout,
483
+ pingTimeout: conf.PingTimeout,
484
+ pings: make(map[[8]byte]chan struct{}),
485
+ reqHeaderMu: make(chan struct{}, 1),
486
+ lastActive: time.Now(),
487
+ internalStateHook: internalStateHook,
488
+ }
489
+ if t.transportTestHooks != nil {
490
+ t.transportTestHooks.newclientconn(cc)
491
+ c = cc.tconn
492
+ }
493
+ if VerboseLogs {
494
+ t.vlogf("http2: Transport creating client conn %p to %v", cc, c.RemoteAddr())
495
+ }
496
+
497
+ cc.cond = sync.NewCond(&cc.mu)
498
+ cc.flow.add(int32(initialWindowSize))
499
+
500
+ // TODO: adjust this writer size to account for frame size +
501
+ // MTU + crypto/tls record padding.
502
+ cc.bw = bufio.NewWriter(stickyErrWriter{
503
+ conn: c,
504
+ timeout: conf.WriteByteTimeout,
505
+ err: &cc.werr,
506
+ })
507
+ cc.br = bufio.NewReader(c)
508
+ cc.fr = NewFramer(cc.bw, cc.br)
509
+ cc.fr.SetMaxReadFrameSize(conf.MaxReadFrameSize)
510
+ if t.CountError != nil {
511
+ cc.fr.countError = t.CountError
512
+ }
513
+ maxHeaderTableSize := conf.MaxDecoderHeaderTableSize
514
+ cc.fr.ReadMetaHeaders = hpack.NewDecoder(maxHeaderTableSize, nil)
515
+ cc.fr.MaxHeaderListSize = t.maxHeaderListSize()
516
+
517
+ cc.henc = hpack.NewEncoder(&cc.hbuf)
518
+ cc.henc.SetMaxDynamicTableSizeLimit(conf.MaxEncoderHeaderTableSize)
519
+ cc.peerMaxHeaderTableSize = initialHeaderTableSize
520
+
521
+ if cs, ok := c.(connectionStater); ok {
522
+ state := cs.ConnectionState()
523
+ cc.tlsState = &state
524
+ }
525
+
526
+ initialSettings := []Setting{
527
+ {ID: SettingEnablePush, Val: 0},
528
+ {ID: SettingInitialWindowSize, Val: uint32(cc.initialStreamRecvWindowSize)},
529
+ }
530
+ initialSettings = append(initialSettings, Setting{ID: SettingMaxFrameSize, Val: conf.MaxReadFrameSize})
531
+ if max := t.maxHeaderListSize(); max != 0 {
532
+ initialSettings = append(initialSettings, Setting{ID: SettingMaxHeaderListSize, Val: max})
533
+ }
534
+ if maxHeaderTableSize != initialHeaderTableSize {
535
+ initialSettings = append(initialSettings, Setting{ID: SettingHeaderTableSize, Val: maxHeaderTableSize})
536
+ }
537
+
538
+ cc.bw.Write(clientPreface)
539
+ cc.fr.WriteSettings(initialSettings...)
540
+ cc.fr.WriteWindowUpdate(0, uint32(conf.MaxUploadBufferPerConnection))
541
+ cc.inflow.init(conf.MaxUploadBufferPerConnection + initialWindowSize)
542
+ cc.bw.Flush()
543
+ if cc.werr != nil {
544
+ cc.Close()
545
+ return nil, cc.werr
546
+ }
547
+
548
+ // Start the idle timer after the connection is fully initialized.
549
+ if d := t.idleConnTimeout(); d != 0 {
550
+ cc.idleTimeout = d
551
+ cc.idleTimer = time.AfterFunc(d, cc.onIdleTimeout)
552
+ }
553
+
554
+ go cc.readLoop()
555
+ return cc, nil
556
+ }
557
+
558
+ func (cc *ClientConn) healthCheck() {
559
+ pingTimeout := cc.pingTimeout
560
+ // We don't need to periodically ping in the health check, because the readLoop of ClientConn will
561
+ // trigger the healthCheck again if there is no frame received.
562
+ ctx, cancel := context.WithTimeout(context.Background(), pingTimeout)
563
+ defer cancel()
564
+ cc.vlogf("http2: Transport sending health check")
565
+ err := cc.Ping(ctx)
566
+ if err != nil {
567
+ cc.vlogf("http2: Transport health check failure: %v", err)
568
+ cc.closeForLostPing()
569
+ } else {
570
+ cc.vlogf("http2: Transport health check success")
571
+ }
572
+ }
573
+
574
+ func (cc *ClientConn) setDoNotReuse() {
575
+ cc.mu.Lock()
576
+ defer cc.mu.Unlock()
577
+ cc.doNotReuse = true
578
+ }
579
+
580
+ func (cc *ClientConn) setGoAway(f *GoAwayFrame) {
581
+ cc.mu.Lock()
582
+ defer cc.mu.Unlock()
583
+
584
+ old := cc.goAway
585
+ cc.goAway = f
586
+
587
+ // Merge the previous and current GoAway error frames.
588
+ if cc.goAwayDebug == "" {
589
+ cc.goAwayDebug = string(f.DebugData())
590
+ }
591
+ if old != nil && old.ErrCode != ErrCodeNo {
592
+ cc.goAway.ErrCode = old.ErrCode
593
+ }
594
+ last := f.LastStreamID
595
+ for streamID, cs := range cc.streams {
596
+ if streamID <= last {
597
+ // The server's GOAWAY indicates that it received this stream.
598
+ // It will either finish processing it, or close the connection
599
+ // without doing so. Either way, leave the stream alone for now.
600
+ continue
601
+ }
602
+ if streamID == 1 && cc.goAway.ErrCode != ErrCodeNo {
603
+ // Don't retry the first stream on a connection if we get a non-NO error.
604
+ // If the server is sending an error on a new connection,
605
+ // retrying the request on a new one probably isn't going to work.
606
+ cs.abortStreamLocked(fmt.Errorf("http2: Transport received GOAWAY from server ErrCode:%v", cc.goAway.ErrCode))
607
+ } else {
608
+ // Aborting the stream with errClentConnGotGoAway indicates that
609
+ // the request should be retried on a new connection.
610
+ cs.abortStreamLocked(errClientConnGotGoAway)
611
+ }
612
+ }
613
+ }
614
+
615
+ func (cc *ClientConn) canTakeNewRequest() bool {
616
+ cc.mu.Lock()
617
+ defer cc.mu.Unlock()
618
+ return cc.canTakeNewRequestLocked()
619
+ }
620
+
621
+ func (cc *ClientConn) reserveNewRequest() bool {
622
+ cc.mu.Lock()
623
+ defer cc.mu.Unlock()
624
+ if st := cc.idleStateLocked(); !st.canTakeNewRequest {
625
+ return false
626
+ }
627
+ cc.streamsReserved++
628
+ return true
629
+ }
630
+
631
+ func (cc *ClientConn) state() ClientConnState {
632
+ cc.wmu.Lock()
633
+ maxConcurrent := cc.maxConcurrentStreams
634
+ if !cc.seenSettings {
635
+ maxConcurrent = 0
636
+ }
637
+ cc.wmu.Unlock()
638
+
639
+ cc.mu.Lock()
640
+ defer cc.mu.Unlock()
641
+ return ClientConnState{
642
+ Closed: cc.closed,
643
+ Closing: cc.closing || cc.singleUse || cc.doNotReuse || cc.goAway != nil,
644
+ StreamsActive: len(cc.streams) + cc.pendingResets,
645
+ StreamsReserved: cc.streamsReserved,
646
+ StreamsPending: cc.pendingRequests,
647
+ LastIdle: cc.lastIdle,
648
+ MaxConcurrentStreams: maxConcurrent,
649
+ }
650
+ }
651
+
652
+ // clientConnIdleState describes the suitability of a client
653
+ // connection to initiate a new RoundTrip request.
654
+ type clientConnIdleState struct {
655
+ canTakeNewRequest bool
656
+ }
657
+
658
+ func (cc *ClientConn) idleState() clientConnIdleState {
659
+ cc.mu.Lock()
660
+ defer cc.mu.Unlock()
661
+ return cc.idleStateLocked()
662
+ }
663
+
664
+ func (cc *ClientConn) idleStateLocked() (st clientConnIdleState) {
665
+ if cc.singleUse && cc.nextStreamID > 1 {
666
+ return
667
+ }
668
+ var maxConcurrentOkay bool
669
+ if cc.strictMaxConcurrentStreams {
670
+ // We'll tell the caller we can take a new request to
671
+ // prevent the caller from dialing a new TCP
672
+ // connection, but then we'll block later before
673
+ // writing it.
674
+ maxConcurrentOkay = true
675
+ } else {
676
+ // We can take a new request if the total of
677
+ // - active streams;
678
+ // - reservation slots for new streams; and
679
+ // - streams for which we have sent a RST_STREAM and a PING,
680
+ // but received no subsequent frame
681
+ // is less than the concurrency limit.
682
+ maxConcurrentOkay = cc.currentRequestCountLocked() < int(cc.maxConcurrentStreams)
683
+ }
684
+
685
+ st.canTakeNewRequest = maxConcurrentOkay && cc.isUsableLocked()
686
+
687
+ // If this connection has never been used for a request and is closed,
688
+ // then let it take a request (which will fail).
689
+ // If the conn was closed for idleness, we're racing the idle timer;
690
+ // don't try to use the conn. (Issue #70515.)
691
+ //
692
+ // This avoids a situation where an error early in a connection's lifetime
693
+ // goes unreported.
694
+ if cc.nextStreamID == 1 && cc.streamsReserved == 0 && cc.closed && !cc.closedOnIdle {
695
+ st.canTakeNewRequest = true
696
+ }
697
+
698
+ return
699
+ }
700
+
701
+ func (cc *ClientConn) isUsableLocked() bool {
702
+ return cc.goAway == nil &&
703
+ !cc.closed &&
704
+ !cc.closing &&
705
+ !cc.doNotReuse &&
706
+ int64(cc.nextStreamID)+2*int64(cc.pendingRequests) < math.MaxInt32 &&
707
+ !cc.tooIdleLocked()
708
+ }
709
+
710
+ // canReserveLocked reports whether a net/http.ClientConn can reserve a slot on this conn.
711
+ //
712
+ // This follows slightly different rules than clientConnIdleState.canTakeNewRequest.
713
+ // We only permit reservations up to the conn's concurrency limit.
714
+ // This differs from ClientConn.ReserveNewRequest, which permits reservations
715
+ // past the limit when StrictMaxConcurrentStreams is set.
716
+ func (cc *ClientConn) canReserveLocked() bool {
717
+ if cc.currentRequestCountLocked() >= int(cc.maxConcurrentStreams) {
718
+ return false
719
+ }
720
+ if !cc.isUsableLocked() {
721
+ return false
722
+ }
723
+ return true
724
+ }
725
+
726
+ // currentRequestCountLocked reports the number of concurrency slots currently in use,
727
+ // including active streams, reserved slots, and reset streams waiting for acknowledgement.
728
+ func (cc *ClientConn) currentRequestCountLocked() int {
729
+ return len(cc.streams) + cc.streamsReserved + cc.pendingResets
730
+ }
731
+
732
+ func (cc *ClientConn) canTakeNewRequestLocked() bool {
733
+ st := cc.idleStateLocked()
734
+ return st.canTakeNewRequest
735
+ }
736
+
737
+ // availableLocked reports the number of concurrency slots available.
738
+ func (cc *ClientConn) availableLocked() int {
739
+ if !cc.canTakeNewRequestLocked() {
740
+ return 0
741
+ }
742
+ return max(0, int(cc.maxConcurrentStreams)-cc.currentRequestCountLocked())
743
+ }
744
+
745
+ // tooIdleLocked reports whether this connection has been been sitting idle
746
+ // for too much wall time.
747
+ func (cc *ClientConn) tooIdleLocked() bool {
748
+ // The Round(0) strips the monontonic clock reading so the
749
+ // times are compared based on their wall time. We don't want
750
+ // to reuse a connection that's been sitting idle during
751
+ // VM/laptop suspend if monotonic time was also frozen.
752
+ return cc.idleTimeout != 0 && !cc.lastIdle.IsZero() && time.Since(cc.lastIdle.Round(0)) > cc.idleTimeout
753
+ }
754
+
755
+ // onIdleTimeout is called from a time.AfterFunc goroutine. It will
756
+ // only be called when we're idle, but because we're coming from a new
757
+ // goroutine, there could be a new request coming in at the same time,
758
+ // so this simply calls the synchronized closeIfIdle to shut down this
759
+ // connection. The timer could just call closeIfIdle, but this is more
760
+ // clear.
761
+ func (cc *ClientConn) onIdleTimeout() {
762
+ cc.closeIfIdle()
763
+ }
764
+
765
+ func (cc *ClientConn) closeConn() {
766
+ t := time.AfterFunc(250*time.Millisecond, cc.forceCloseConn)
767
+ defer t.Stop()
768
+ cc.tconn.Close()
769
+ cc.maybeCallStateHook()
770
+ }
771
+
772
+ // A tls.Conn.Close can hang for a long time if the peer is unresponsive.
773
+ // Try to shut it down more aggressively.
774
+ func (cc *ClientConn) forceCloseConn() {
775
+ tc, ok := cc.tconn.(*tls.Conn)
776
+ if !ok {
777
+ return
778
+ }
779
+ if nc := tc.NetConn(); nc != nil {
780
+ nc.Close()
781
+ }
782
+ }
783
+
784
+ func (cc *ClientConn) closeIfIdle() {
785
+ cc.mu.Lock()
786
+ if len(cc.streams) > 0 || cc.streamsReserved > 0 {
787
+ cc.mu.Unlock()
788
+ return
789
+ }
790
+ cc.closed = true
791
+ cc.closedOnIdle = true
792
+ nextID := cc.nextStreamID
793
+ // TODO: do clients send GOAWAY too? maybe? Just Close:
794
+ cc.mu.Unlock()
795
+
796
+ if VerboseLogs {
797
+ cc.vlogf("http2: Transport closing idle conn %p (forSingleUse=%v, maxStream=%v)", cc, cc.singleUse, nextID-2)
798
+ }
799
+ cc.closeConn()
800
+ }
801
+
802
+ func (cc *ClientConn) stopIdleTimer() {
803
+ if cc.idleTimer != nil {
804
+ cc.idleTimer.Stop()
805
+ }
806
+ }
807
+
808
+ func (cc *ClientConn) isDoNotReuseAndIdle() bool {
809
+ cc.mu.Lock()
810
+ defer cc.mu.Unlock()
811
+ return cc.doNotReuse && len(cc.streams) == 0
812
+ }
813
+
814
+ var shutdownEnterWaitStateHook = func() {}
815
+
816
+ func (cc *ClientConn) shutdown(ctx context.Context) error {
817
+ if err := cc.sendGoAway(); err != nil {
818
+ return err
819
+ }
820
+ // Wait for all in-flight streams to complete or connection to close
821
+ done := make(chan struct{})
822
+ cancelled := false // guarded by cc.mu
823
+ go func() {
824
+ cc.mu.Lock()
825
+ defer cc.mu.Unlock()
826
+ for {
827
+ if len(cc.streams) == 0 || cc.closed {
828
+ cc.closed = true
829
+ close(done)
830
+ break
831
+ }
832
+ if cancelled {
833
+ break
834
+ }
835
+ cc.cond.Wait()
836
+ }
837
+ }()
838
+ shutdownEnterWaitStateHook()
839
+ select {
840
+ case <-done:
841
+ cc.closeConn()
842
+ return nil
843
+ case <-ctx.Done():
844
+ cc.mu.Lock()
845
+ // Free the goroutine above
846
+ cancelled = true
847
+ cc.cond.Broadcast()
848
+ cc.mu.Unlock()
849
+ return ctx.Err()
850
+ }
851
+ }
852
+
853
+ func (cc *ClientConn) sendGoAway() error {
854
+ cc.mu.Lock()
855
+ closing := cc.closing
856
+ cc.closing = true
857
+ maxStreamID := cc.nextStreamID
858
+ cc.mu.Unlock()
859
+ if closing {
860
+ // GOAWAY sent already
861
+ return nil
862
+ }
863
+
864
+ cc.wmu.Lock()
865
+ defer cc.wmu.Unlock()
866
+ // Send a graceful shutdown frame to server
867
+ if err := cc.fr.WriteGoAway(maxStreamID, ErrCodeNo, nil); err != nil {
868
+ return err
869
+ }
870
+ if err := cc.bw.Flush(); err != nil {
871
+ return err
872
+ }
873
+ // Prevent new requests
874
+ return nil
875
+ }
876
+
877
+ // closes the client connection immediately. In-flight requests are interrupted.
878
+ // err is sent to streams.
879
+ func (cc *ClientConn) closeForError(err error) {
880
+ cc.mu.Lock()
881
+ cc.closed = true
882
+ for _, cs := range cc.streams {
883
+ cs.abortStreamLocked(err)
884
+ }
885
+ cc.cond.Broadcast()
886
+ cc.mu.Unlock()
887
+ cc.closeConn()
888
+ }
889
+
890
+ func (cc *ClientConn) close() error {
891
+ cc.closeForError(errClientConnForceClosed)
892
+ return nil
893
+ }
894
+
895
+ // closes the client connection immediately. In-flight requests are interrupted.
896
+ func (cc *ClientConn) closeForLostPing() {
897
+ err := errors.New("http2: client connection lost")
898
+ if f := cc.t.CountError; f != nil {
899
+ f("conn_close_lost_ping")
900
+ }
901
+ cc.closeForError(err)
902
+ }
903
+
904
+ // errRequestCanceled is a copy of net/http's errRequestCanceled because it's not
905
+ // exported. At least they'll be DeepEqual for h1-vs-h2 comparisons tests.
906
+ var errRequestCanceled = errors.New("net/http: request canceled")
907
+
908
+ func (cc *ClientConn) responseHeaderTimeout() time.Duration {
909
+ if cc.t.t1 != nil {
910
+ return cc.t.t1.ResponseHeaderTimeout
911
+ }
912
+ // No way to do this (yet?) with just an http2.Transport. Probably
913
+ // no need. Request.Cancel this is the new way. We only need to support
914
+ // this for compatibility with the old http.Transport fields when
915
+ // we're doing transparent http2.
916
+ return 0
917
+ }
918
+
919
+ // actualContentLength returns a sanitized version of
920
+ // req.ContentLength, where 0 actually means zero (not unknown) and -1
921
+ // means unknown.
922
+ func actualContentLength(req *http.Request) int64 {
923
+ if req.Body == nil || req.Body == http.NoBody {
924
+ return 0
925
+ }
926
+ if req.ContentLength != 0 {
927
+ return req.ContentLength
928
+ }
929
+ return -1
930
+ }
931
+
932
+ func (cc *ClientConn) decrStreamReservations() {
933
+ cc.mu.Lock()
934
+ defer cc.mu.Unlock()
935
+ cc.decrStreamReservationsLocked()
936
+ }
937
+
938
+ func (cc *ClientConn) decrStreamReservationsLocked() {
939
+ if cc.streamsReserved > 0 {
940
+ cc.streamsReserved--
941
+ }
942
+ }
943
+
944
+ func (cc *ClientConn) roundTrip(req *http.Request) (*http.Response, error) {
945
+ return cc.internalRoundTrip(req, nil)
946
+ }
947
+
948
+ func (cc *ClientConn) internalRoundTrip(req *http.Request, streamf func(*clientStream)) (*http.Response, error) {
949
+ ctx := req.Context()
950
+ cs := &clientStream{
951
+ cc: cc,
952
+ ctx: ctx,
953
+ reqCancel: req.Cancel,
954
+ isHead: req.Method == "HEAD",
955
+ reqBody: req.Body,
956
+ reqBodyContentLength: actualContentLength(req),
957
+ trace: httptrace.ContextClientTrace(ctx),
958
+ peerClosed: make(chan struct{}),
959
+ abort: make(chan struct{}),
960
+ respHeaderRecv: make(chan struct{}),
961
+ donec: make(chan struct{}),
962
+ }
963
+
964
+ cs.requestedGzip = httpcommon.IsRequestGzip(req.Method, req.Header, cc.t.disableCompression())
965
+
966
+ go cs.doRequest(req, streamf)
967
+
968
+ waitDone := func() error {
969
+ select {
970
+ case <-cs.donec:
971
+ return nil
972
+ case <-ctx.Done():
973
+ return ctx.Err()
974
+ case <-cs.reqCancel:
975
+ return errRequestCanceled
976
+ }
977
+ }
978
+
979
+ handleResponseHeaders := func() (*http.Response, error) {
980
+ res := cs.res
981
+ if res.StatusCode > 299 {
982
+ // On error or status code 3xx, 4xx, 5xx, etc abort any
983
+ // ongoing write, assuming that the server doesn't care
984
+ // about our request body. If the server replied with 1xx or
985
+ // 2xx, however, then assume the server DOES potentially
986
+ // want our body (e.g. full-duplex streaming:
987
+ // golang.org/issue/13444). If it turns out the server
988
+ // doesn't, they'll RST_STREAM us soon enough. This is a
989
+ // heuristic to avoid adding knobs to Transport. Hopefully
990
+ // we can keep it.
991
+ cs.abortRequestBodyWrite()
992
+ }
993
+ res.Request = req
994
+ res.TLS = cc.tlsState
995
+ if res.Body == noBody && actualContentLength(req) == 0 {
996
+ // If there isn't a request or response body still being
997
+ // written, then wait for the stream to be closed before
998
+ // RoundTrip returns.
999
+ if err := waitDone(); err != nil {
1000
+ return nil, err
1001
+ }
1002
+ }
1003
+ return res, nil
1004
+ }
1005
+
1006
+ cancelRequest := func(cs *clientStream, err error) error {
1007
+ cs.cc.mu.Lock()
1008
+ bodyClosed := cs.reqBodyClosed
1009
+ cs.cc.mu.Unlock()
1010
+ // Wait for the request body to be closed.
1011
+ //
1012
+ // If nothing closed the body before now, abortStreamLocked
1013
+ // will have started a goroutine to close it.
1014
+ //
1015
+ // Closing the body before returning avoids a race condition
1016
+ // with net/http checking its readTrackingBody to see if the
1017
+ // body was read from or closed. See golang/go#60041.
1018
+ //
1019
+ // The body is closed in a separate goroutine without the
1020
+ // connection mutex held, but dropping the mutex before waiting
1021
+ // will keep us from holding it indefinitely if the body
1022
+ // close is slow for some reason.
1023
+ if bodyClosed != nil {
1024
+ <-bodyClosed
1025
+ }
1026
+ return err
1027
+ }
1028
+
1029
+ for {
1030
+ select {
1031
+ case <-cs.respHeaderRecv:
1032
+ return handleResponseHeaders()
1033
+ case <-cs.abort:
1034
+ select {
1035
+ case <-cs.respHeaderRecv:
1036
+ // If both cs.respHeaderRecv and cs.abort are signaling,
1037
+ // pick respHeaderRecv. The server probably wrote the
1038
+ // response and immediately reset the stream.
1039
+ // golang.org/issue/49645
1040
+ return handleResponseHeaders()
1041
+ default:
1042
+ waitDone()
1043
+ return nil, cs.abortErr
1044
+ }
1045
+ case <-ctx.Done():
1046
+ err := ctx.Err()
1047
+ cs.abortStream(err)
1048
+ return nil, cancelRequest(cs, err)
1049
+ case <-cs.reqCancel:
1050
+ cs.abortStream(errRequestCanceled)
1051
+ return nil, cancelRequest(cs, errRequestCanceled)
1052
+ }
1053
+ }
1054
+ }
1055
+
1056
+ // doRequest runs for the duration of the request lifetime.
1057
+ //
1058
+ // It sends the request and performs post-request cleanup (closing Request.Body, etc.).
1059
+ func (cs *clientStream) doRequest(req *http.Request, streamf func(*clientStream)) {
1060
+ err := cs.writeRequest(req, streamf)
1061
+ cs.cleanupWriteRequest(err)
1062
+ }
1063
+
1064
+ var errExtendedConnectNotSupported = errors.New("net/http: extended connect not supported by peer")
1065
+
1066
+ // writeRequest sends a request.
1067
+ //
1068
+ // It returns nil after the request is written, the response read,
1069
+ // and the request stream is half-closed by the peer.
1070
+ //
1071
+ // It returns non-nil if the request ends otherwise.
1072
+ // If the returned error is StreamError, the error Code may be used in resetting the stream.
1073
+ func (cs *clientStream) writeRequest(req *http.Request, streamf func(*clientStream)) (err error) {
1074
+ cc := cs.cc
1075
+ ctx := cs.ctx
1076
+
1077
+ // wait for setting frames to be received, a server can change this value later,
1078
+ // but we just wait for the first settings frame
1079
+ var isExtendedConnect bool
1080
+ if req.Method == "CONNECT" && req.Header.Get(":protocol") != "" {
1081
+ isExtendedConnect = true
1082
+ }
1083
+
1084
+ // Acquire the new-request lock by writing to reqHeaderMu.
1085
+ // This lock guards the critical section covering allocating a new stream ID
1086
+ // (requires mu) and creating the stream (requires wmu).
1087
+ if cc.reqHeaderMu == nil {
1088
+ panic("RoundTrip on uninitialized ClientConn") // for tests
1089
+ }
1090
+ if isExtendedConnect {
1091
+ select {
1092
+ case <-cs.reqCancel:
1093
+ return errRequestCanceled
1094
+ case <-ctx.Done():
1095
+ return ctx.Err()
1096
+ case <-cc.seenSettingsChan:
1097
+ if !cc.extendedConnectAllowed {
1098
+ return errExtendedConnectNotSupported
1099
+ }
1100
+ }
1101
+ }
1102
+ select {
1103
+ case cc.reqHeaderMu <- struct{}{}:
1104
+ case <-cs.reqCancel:
1105
+ return errRequestCanceled
1106
+ case <-ctx.Done():
1107
+ return ctx.Err()
1108
+ }
1109
+
1110
+ cc.mu.Lock()
1111
+ if cc.idleTimer != nil {
1112
+ cc.idleTimer.Stop()
1113
+ }
1114
+ cc.decrStreamReservationsLocked()
1115
+ if err := cc.awaitOpenSlotForStreamLocked(cs); err != nil {
1116
+ cc.mu.Unlock()
1117
+ <-cc.reqHeaderMu
1118
+ return err
1119
+ }
1120
+ cc.addStreamLocked(cs) // assigns stream ID
1121
+ if isConnectionCloseRequest(req) {
1122
+ cc.doNotReuse = true
1123
+ }
1124
+ cc.mu.Unlock()
1125
+
1126
+ if streamf != nil {
1127
+ streamf(cs)
1128
+ }
1129
+
1130
+ continueTimeout := cc.t.expectContinueTimeout()
1131
+ if continueTimeout != 0 {
1132
+ if !httpguts.HeaderValuesContainsToken(req.Header["Expect"], "100-continue") {
1133
+ continueTimeout = 0
1134
+ } else {
1135
+ cs.on100 = make(chan struct{}, 1)
1136
+ }
1137
+ }
1138
+
1139
+ // Past this point (where we send request headers), it is possible for
1140
+ // RoundTrip to return successfully. Since the RoundTrip contract permits
1141
+ // the caller to "mutate or reuse" the Request after closing the Response's Body,
1142
+ // we must take care when referencing the Request from here on.
1143
+ err = cs.encodeAndWriteHeaders(req)
1144
+ <-cc.reqHeaderMu
1145
+ if err != nil {
1146
+ return err
1147
+ }
1148
+
1149
+ hasBody := cs.reqBodyContentLength != 0
1150
+ if !hasBody {
1151
+ cs.sentEndStream = true
1152
+ } else {
1153
+ if continueTimeout != 0 {
1154
+ traceWait100Continue(cs.trace)
1155
+ timer := time.NewTimer(continueTimeout)
1156
+ select {
1157
+ case <-timer.C:
1158
+ err = nil
1159
+ case <-cs.on100:
1160
+ err = nil
1161
+ case <-cs.abort:
1162
+ err = cs.abortErr
1163
+ case <-ctx.Done():
1164
+ err = ctx.Err()
1165
+ case <-cs.reqCancel:
1166
+ err = errRequestCanceled
1167
+ }
1168
+ timer.Stop()
1169
+ if err != nil {
1170
+ traceWroteRequest(cs.trace, err)
1171
+ return err
1172
+ }
1173
+ }
1174
+
1175
+ if err = cs.writeRequestBody(req); err != nil {
1176
+ if err != errStopReqBodyWrite {
1177
+ traceWroteRequest(cs.trace, err)
1178
+ return err
1179
+ }
1180
+ } else {
1181
+ cs.sentEndStream = true
1182
+ }
1183
+ }
1184
+
1185
+ traceWroteRequest(cs.trace, err)
1186
+
1187
+ var respHeaderTimer <-chan time.Time
1188
+ var respHeaderRecv chan struct{}
1189
+ if d := cc.responseHeaderTimeout(); d != 0 {
1190
+ timer := time.NewTimer(d)
1191
+ defer timer.Stop()
1192
+ respHeaderTimer = timer.C
1193
+ respHeaderRecv = cs.respHeaderRecv
1194
+ }
1195
+ // Wait until the peer half-closes its end of the stream,
1196
+ // or until the request is aborted (via context, error, or otherwise),
1197
+ // whichever comes first.
1198
+ for {
1199
+ select {
1200
+ case <-cs.peerClosed:
1201
+ return nil
1202
+ case <-respHeaderTimer:
1203
+ return errTimeout
1204
+ case <-respHeaderRecv:
1205
+ respHeaderRecv = nil
1206
+ respHeaderTimer = nil // keep waiting for END_STREAM
1207
+ case <-cs.abort:
1208
+ return cs.abortErr
1209
+ case <-ctx.Done():
1210
+ return ctx.Err()
1211
+ case <-cs.reqCancel:
1212
+ return errRequestCanceled
1213
+ }
1214
+ }
1215
+ }
1216
+
1217
+ func (cs *clientStream) encodeAndWriteHeaders(req *http.Request) error {
1218
+ cc := cs.cc
1219
+ ctx := cs.ctx
1220
+
1221
+ cc.wmu.Lock()
1222
+ defer cc.wmu.Unlock()
1223
+
1224
+ // If the request was canceled while waiting for cc.mu, just quit.
1225
+ select {
1226
+ case <-cs.abort:
1227
+ return cs.abortErr
1228
+ case <-ctx.Done():
1229
+ return ctx.Err()
1230
+ case <-cs.reqCancel:
1231
+ return errRequestCanceled
1232
+ default:
1233
+ }
1234
+
1235
+ // Encode headers.
1236
+ //
1237
+ // we send: HEADERS{1}, CONTINUATION{0,} + DATA{0,} (DATA is
1238
+ // sent by writeRequestBody below, along with any Trailers,
1239
+ // again in form HEADERS{1}, CONTINUATION{0,})
1240
+ cc.hbuf.Reset()
1241
+ res, err := encodeRequestHeaders(req, cs.requestedGzip, cc.peerMaxHeaderListSize, func(name, value string) {
1242
+ cc.writeHeader(name, value)
1243
+ })
1244
+ if err != nil {
1245
+ return fmt.Errorf("http2: %w", err)
1246
+ }
1247
+ hdrs := cc.hbuf.Bytes()
1248
+
1249
+ // Write the request.
1250
+ endStream := !res.HasBody && !res.HasTrailers
1251
+ cs.sentHeaders = true
1252
+ err = cc.writeHeaders(cs.ID, endStream, int(cc.maxFrameSize), hdrs)
1253
+ traceWroteHeaders(cs.trace)
1254
+ return err
1255
+ }
1256
+
1257
+ func encodeRequestHeaders(req *http.Request, addGzipHeader bool, peerMaxHeaderListSize uint64, headerf func(name, value string)) (httpcommon.EncodeHeadersResult, error) {
1258
+ return httpcommon.EncodeHeaders(req.Context(), httpcommon.EncodeHeadersParam{
1259
+ Request: httpcommon.Request{
1260
+ Header: req.Header,
1261
+ Trailer: req.Trailer,
1262
+ URL: req.URL,
1263
+ Host: req.Host,
1264
+ Method: req.Method,
1265
+ ActualContentLength: actualContentLength(req),
1266
+ },
1267
+ AddGzipHeader: addGzipHeader,
1268
+ PeerMaxHeaderListSize: peerMaxHeaderListSize,
1269
+ DefaultUserAgent: defaultUserAgent,
1270
+ }, headerf)
1271
+ }
1272
+
1273
+ // cleanupWriteRequest performs post-request tasks.
1274
+ //
1275
+ // If err (the result of writeRequest) is non-nil and the stream is not closed,
1276
+ // cleanupWriteRequest will send a reset to the peer.
1277
+ func (cs *clientStream) cleanupWriteRequest(err error) {
1278
+ cc := cs.cc
1279
+
1280
+ if cs.ID == 0 {
1281
+ // We were canceled before creating the stream, so return our reservation.
1282
+ cc.decrStreamReservations()
1283
+ }
1284
+
1285
+ // TODO: write h12Compare test showing whether
1286
+ // Request.Body is closed by the Transport,
1287
+ // and in multiple cases: server replies <=299 and >299
1288
+ // while still writing request body
1289
+ cc.mu.Lock()
1290
+ mustCloseBody := false
1291
+ if cs.reqBody != nil && cs.reqBodyClosed == nil {
1292
+ mustCloseBody = true
1293
+ cs.reqBodyClosed = make(chan struct{})
1294
+ }
1295
+ bodyClosed := cs.reqBodyClosed
1296
+ closeOnIdle := cc.singleUse || cc.doNotReuse || cc.t.disableKeepAlives() || cc.goAway != nil
1297
+ // Have we read any frames from the connection since sending this request?
1298
+ readSinceStream := cc.readBeforeStreamID > cs.ID
1299
+ cc.mu.Unlock()
1300
+ if mustCloseBody {
1301
+ cs.reqBody.Close()
1302
+ close(bodyClosed)
1303
+ }
1304
+ if bodyClosed != nil {
1305
+ <-bodyClosed
1306
+ }
1307
+
1308
+ if err != nil && cs.sentEndStream {
1309
+ // If the connection is closed immediately after the response is read,
1310
+ // we may be aborted before finishing up here. If the stream was closed
1311
+ // cleanly on both sides, there is no error.
1312
+ select {
1313
+ case <-cs.peerClosed:
1314
+ err = nil
1315
+ default:
1316
+ }
1317
+ }
1318
+ if err != nil {
1319
+ cs.abortStream(err) // possibly redundant, but harmless
1320
+ if cs.sentHeaders {
1321
+ if se, ok := err.(StreamError); ok {
1322
+ if se.Cause != errFromPeer {
1323
+ cc.writeStreamReset(cs.ID, se.Code, false, err)
1324
+ }
1325
+ } else {
1326
+ // We're cancelling an in-flight request.
1327
+ //
1328
+ // This could be due to the server becoming unresponsive.
1329
+ // To avoid sending too many requests on a dead connection,
1330
+ // if we haven't read any frames from the connection since
1331
+ // sending this request, we let it continue to consume
1332
+ // a concurrency slot until we can confirm the server is
1333
+ // still responding.
1334
+ // We do this by sending a PING frame along with the RST_STREAM
1335
+ // (unless a ping is already in flight).
1336
+ //
1337
+ // For simplicity, we don't bother tracking the PING payload:
1338
+ // We reset cc.pendingResets any time we receive a PING ACK.
1339
+ //
1340
+ // We skip this if the conn is going to be closed on idle,
1341
+ // because it's short lived and will probably be closed before
1342
+ // we get the ping response.
1343
+ ping := false
1344
+ if !closeOnIdle && !readSinceStream {
1345
+ cc.mu.Lock()
1346
+ // rstStreamPingsBlocked works around a gRPC behavior:
1347
+ // see comment on the field for details.
1348
+ if !cc.rstStreamPingsBlocked {
1349
+ if cc.pendingResets == 0 {
1350
+ ping = true
1351
+ }
1352
+ cc.pendingResets++
1353
+ }
1354
+ cc.mu.Unlock()
1355
+ }
1356
+ cc.writeStreamReset(cs.ID, ErrCodeCancel, ping, err)
1357
+ }
1358
+ }
1359
+ cs.bufPipe.CloseWithError(err) // no-op if already closed
1360
+ } else {
1361
+ if cs.sentHeaders && !cs.sentEndStream {
1362
+ cc.writeStreamReset(cs.ID, ErrCodeNo, false, nil)
1363
+ }
1364
+ cs.bufPipe.CloseWithError(errRequestCanceled)
1365
+ }
1366
+ if cs.ID != 0 {
1367
+ cc.forgetStreamID(cs.ID)
1368
+ }
1369
+
1370
+ cc.wmu.Lock()
1371
+ werr := cc.werr
1372
+ cc.wmu.Unlock()
1373
+ if werr != nil {
1374
+ cc.Close()
1375
+ }
1376
+
1377
+ close(cs.donec)
1378
+ cc.maybeCallStateHook()
1379
+ }
1380
+
1381
+ // awaitOpenSlotForStreamLocked waits until len(streams) < maxConcurrentStreams.
1382
+ // Must hold cc.mu.
1383
+ func (cc *ClientConn) awaitOpenSlotForStreamLocked(cs *clientStream) error {
1384
+ for {
1385
+ if cc.closed && cc.nextStreamID == 1 && cc.streamsReserved == 0 {
1386
+ // This is the very first request sent to this connection.
1387
+ // Return a fatal error which aborts the retry loop.
1388
+ return errClientConnNotEstablished
1389
+ }
1390
+ cc.lastActive = time.Now()
1391
+ if cc.closed || !cc.canTakeNewRequestLocked() {
1392
+ return errClientConnUnusable
1393
+ }
1394
+ cc.lastIdle = time.Time{}
1395
+ if cc.currentRequestCountLocked() < int(cc.maxConcurrentStreams) {
1396
+ return nil
1397
+ }
1398
+ cc.pendingRequests++
1399
+ cc.cond.Wait()
1400
+ cc.pendingRequests--
1401
+ select {
1402
+ case <-cs.abort:
1403
+ return cs.abortErr
1404
+ default:
1405
+ }
1406
+ }
1407
+ }
1408
+
1409
+ // requires cc.wmu be held
1410
+ func (cc *ClientConn) writeHeaders(streamID uint32, endStream bool, maxFrameSize int, hdrs []byte) error {
1411
+ first := true // first frame written (HEADERS is first, then CONTINUATION)
1412
+ for len(hdrs) > 0 && cc.werr == nil {
1413
+ chunk := hdrs
1414
+ if len(chunk) > maxFrameSize {
1415
+ chunk = chunk[:maxFrameSize]
1416
+ }
1417
+ hdrs = hdrs[len(chunk):]
1418
+ endHeaders := len(hdrs) == 0
1419
+ if first {
1420
+ cc.fr.WriteHeaders(HeadersFrameParam{
1421
+ StreamID: streamID,
1422
+ BlockFragment: chunk,
1423
+ EndStream: endStream,
1424
+ EndHeaders: endHeaders,
1425
+ })
1426
+ first = false
1427
+ } else {
1428
+ cc.fr.WriteContinuation(streamID, endHeaders, chunk)
1429
+ }
1430
+ }
1431
+ cc.bw.Flush()
1432
+ return cc.werr
1433
+ }
1434
+
1435
+ // internal error values; they don't escape to callers
1436
+ var (
1437
+ // abort request body write; don't send cancel
1438
+ errStopReqBodyWrite = errors.New("http2: aborting request body write")
1439
+
1440
+ // abort request body write, but send stream reset of cancel.
1441
+ errStopReqBodyWriteAndCancel = errors.New("http2: canceling request")
1442
+
1443
+ errReqBodyTooLong = errors.New("http2: request body larger than specified content length")
1444
+ )
1445
+
1446
+ // frameScratchBufferLen returns the length of a buffer to use for
1447
+ // outgoing request bodies to read/write to/from.
1448
+ //
1449
+ // It returns max(1, min(peer's advertised max frame size,
1450
+ // Request.ContentLength+1, 512KB)).
1451
+ func (cs *clientStream) frameScratchBufferLen(maxFrameSize int) int {
1452
+ const max = 512 << 10
1453
+ n := int64(maxFrameSize)
1454
+ if n > max {
1455
+ n = max
1456
+ }
1457
+ if cl := cs.reqBodyContentLength; cl != -1 && cl+1 < n {
1458
+ // Add an extra byte past the declared content-length to
1459
+ // give the caller's Request.Body io.Reader a chance to
1460
+ // give us more bytes than they declared, so we can catch it
1461
+ // early.
1462
+ n = cl + 1
1463
+ }
1464
+ if n < 1 {
1465
+ return 1
1466
+ }
1467
+ return int(n) // doesn't truncate; max is 512K
1468
+ }
1469
+
1470
+ // Seven bufPools manage different frame sizes. This helps to avoid scenarios where long-running
1471
+ // streaming requests using small frame sizes occupy large buffers initially allocated for prior
1472
+ // requests needing big buffers. The size ranges are as follows:
1473
+ // {0 KB, 16 KB], {16 KB, 32 KB], {32 KB, 64 KB], {64 KB, 128 KB], {128 KB, 256 KB],
1474
+ // {256 KB, 512 KB], {512 KB, infinity}
1475
+ // In practice, the maximum scratch buffer size should not exceed 512 KB due to
1476
+ // frameScratchBufferLen(maxFrameSize), thus the "infinity pool" should never be used.
1477
+ // It exists mainly as a safety measure, for potential future increases in max buffer size.
1478
+ var bufPools [7]sync.Pool // of *[]byte
1479
+ func bufPoolIndex(size int) int {
1480
+ if size <= 16384 {
1481
+ return 0
1482
+ }
1483
+ size -= 1
1484
+ bits := bits.Len(uint(size))
1485
+ index := bits - 14
1486
+ if index >= len(bufPools) {
1487
+ return len(bufPools) - 1
1488
+ }
1489
+ return index
1490
+ }
1491
+
1492
+ func (cs *clientStream) writeRequestBody(req *http.Request) (err error) {
1493
+ cc := cs.cc
1494
+ body := cs.reqBody
1495
+ sentEnd := false // whether we sent the final DATA frame w/ END_STREAM
1496
+
1497
+ hasTrailers := req.Trailer != nil
1498
+ remainLen := cs.reqBodyContentLength
1499
+ hasContentLen := remainLen != -1
1500
+
1501
+ cc.mu.Lock()
1502
+ maxFrameSize := int(cc.maxFrameSize)
1503
+ cc.mu.Unlock()
1504
+
1505
+ // Scratch buffer for reading into & writing from.
1506
+ scratchLen := cs.frameScratchBufferLen(maxFrameSize)
1507
+ var buf []byte
1508
+ index := bufPoolIndex(scratchLen)
1509
+ if bp, ok := bufPools[index].Get().(*[]byte); ok && len(*bp) >= scratchLen {
1510
+ defer bufPools[index].Put(bp)
1511
+ buf = *bp
1512
+ } else {
1513
+ buf = make([]byte, scratchLen)
1514
+ defer bufPools[index].Put(&buf)
1515
+ }
1516
+
1517
+ var sawEOF bool
1518
+ for !sawEOF {
1519
+ n, err := body.Read(buf)
1520
+ if hasContentLen {
1521
+ remainLen -= int64(n)
1522
+ if remainLen == 0 && err == nil {
1523
+ // The request body's Content-Length was predeclared and
1524
+ // we just finished reading it all, but the underlying io.Reader
1525
+ // returned the final chunk with a nil error (which is one of
1526
+ // the two valid things a Reader can do at EOF). Because we'd prefer
1527
+ // to send the END_STREAM bit early, double-check that we're actually
1528
+ // at EOF. Subsequent reads should return (0, EOF) at this point.
1529
+ // If either value is different, we return an error in one of two ways below.
1530
+ var scratch [1]byte
1531
+ var n1 int
1532
+ n1, err = body.Read(scratch[:])
1533
+ remainLen -= int64(n1)
1534
+ }
1535
+ if remainLen < 0 {
1536
+ err = errReqBodyTooLong
1537
+ return err
1538
+ }
1539
+ }
1540
+ if err != nil {
1541
+ cc.mu.Lock()
1542
+ bodyClosed := cs.reqBodyClosed != nil
1543
+ cc.mu.Unlock()
1544
+ switch {
1545
+ case bodyClosed:
1546
+ return errStopReqBodyWrite
1547
+ case err == io.EOF:
1548
+ sawEOF = true
1549
+ err = nil
1550
+ default:
1551
+ return err
1552
+ }
1553
+ }
1554
+
1555
+ remain := buf[:n]
1556
+ for len(remain) > 0 && err == nil {
1557
+ var allowed int32
1558
+ allowed, err = cs.awaitFlowControl(len(remain))
1559
+ if err != nil {
1560
+ return err
1561
+ }
1562
+ cc.wmu.Lock()
1563
+ data := remain[:allowed]
1564
+ remain = remain[allowed:]
1565
+ sentEnd = sawEOF && len(remain) == 0 && !hasTrailers
1566
+ err = cc.fr.WriteData(cs.ID, sentEnd, data)
1567
+ if err == nil {
1568
+ // TODO(bradfitz): this flush is for latency, not bandwidth.
1569
+ // Most requests won't need this. Make this opt-in or
1570
+ // opt-out? Use some heuristic on the body type? Nagel-like
1571
+ // timers? Based on 'n'? Only last chunk of this for loop,
1572
+ // unless flow control tokens are low? For now, always.
1573
+ // If we change this, see comment below.
1574
+ err = cc.bw.Flush()
1575
+ }
1576
+ cc.wmu.Unlock()
1577
+ }
1578
+ if err != nil {
1579
+ return err
1580
+ }
1581
+ }
1582
+
1583
+ if sentEnd {
1584
+ // Already sent END_STREAM (which implies we have no
1585
+ // trailers) and flushed, because currently all
1586
+ // WriteData frames above get a flush. So we're done.
1587
+ return nil
1588
+ }
1589
+
1590
+ // Since the RoundTrip contract permits the caller to "mutate or reuse"
1591
+ // a request after the Response's Body is closed, verify that this hasn't
1592
+ // happened before accessing the trailers.
1593
+ cc.mu.Lock()
1594
+ trailer := req.Trailer
1595
+ err = cs.abortErr
1596
+ cc.mu.Unlock()
1597
+ if err != nil {
1598
+ return err
1599
+ }
1600
+
1601
+ cc.wmu.Lock()
1602
+ defer cc.wmu.Unlock()
1603
+ var trls []byte
1604
+ if len(trailer) > 0 {
1605
+ trls, err = cc.encodeTrailers(trailer)
1606
+ if err != nil {
1607
+ return err
1608
+ }
1609
+ }
1610
+
1611
+ // Two ways to send END_STREAM: either with trailers, or
1612
+ // with an empty DATA frame.
1613
+ if len(trls) > 0 {
1614
+ err = cc.writeHeaders(cs.ID, true, maxFrameSize, trls)
1615
+ } else {
1616
+ err = cc.fr.WriteData(cs.ID, true, nil)
1617
+ }
1618
+ if ferr := cc.bw.Flush(); ferr != nil && err == nil {
1619
+ err = ferr
1620
+ }
1621
+ return err
1622
+ }
1623
+
1624
+ // awaitFlowControl waits for [1, min(maxBytes, cc.cs.maxFrameSize)] flow
1625
+ // control tokens from the server.
1626
+ // It returns either the non-zero number of tokens taken or an error
1627
+ // if the stream is dead.
1628
+ func (cs *clientStream) awaitFlowControl(maxBytes int) (taken int32, err error) {
1629
+ cc := cs.cc
1630
+ ctx := cs.ctx
1631
+ cc.mu.Lock()
1632
+ defer cc.mu.Unlock()
1633
+ for {
1634
+ if cc.closed {
1635
+ return 0, errClientConnClosed
1636
+ }
1637
+ if cs.reqBodyClosed != nil {
1638
+ return 0, errStopReqBodyWrite
1639
+ }
1640
+ select {
1641
+ case <-cs.abort:
1642
+ return 0, cs.abortErr
1643
+ case <-ctx.Done():
1644
+ return 0, ctx.Err()
1645
+ case <-cs.reqCancel:
1646
+ return 0, errRequestCanceled
1647
+ default:
1648
+ }
1649
+ if a := cs.flow.available(); a > 0 {
1650
+ take := a
1651
+ if int(take) > maxBytes {
1652
+
1653
+ take = int32(maxBytes) // can't truncate int; take is int32
1654
+ }
1655
+ if take > int32(cc.maxFrameSize) {
1656
+ take = int32(cc.maxFrameSize)
1657
+ }
1658
+ cs.flow.take(take)
1659
+ return take, nil
1660
+ }
1661
+ cc.cond.Wait()
1662
+ }
1663
+ }
1664
+
1665
+ // requires cc.wmu be held.
1666
+ func (cc *ClientConn) encodeTrailers(trailer http.Header) ([]byte, error) {
1667
+ cc.hbuf.Reset()
1668
+
1669
+ hlSize := uint64(0)
1670
+ for k, vv := range trailer {
1671
+ for _, v := range vv {
1672
+ hf := hpack.HeaderField{Name: k, Value: v}
1673
+ hlSize += uint64(hf.Size())
1674
+ }
1675
+ }
1676
+ if hlSize > cc.peerMaxHeaderListSize {
1677
+ return nil, errRequestHeaderListSize
1678
+ }
1679
+
1680
+ for k, vv := range trailer {
1681
+ lowKey, ascii := httpcommon.LowerHeader(k)
1682
+ if !ascii {
1683
+ // Skip writing invalid headers. Per RFC 7540, Section 8.1.2, header
1684
+ // field names have to be ASCII characters (just as in HTTP/1.x).
1685
+ continue
1686
+ }
1687
+ // Transfer-Encoding, etc.. have already been filtered at the
1688
+ // start of RoundTrip
1689
+ for _, v := range vv {
1690
+ cc.writeHeader(lowKey, v)
1691
+ }
1692
+ }
1693
+ return cc.hbuf.Bytes(), nil
1694
+ }
1695
+
1696
+ func (cc *ClientConn) writeHeader(name, value string) {
1697
+ if VerboseLogs {
1698
+ log.Printf("http2: Transport encoding header %q = %q", name, value)
1699
+ }
1700
+ cc.henc.WriteField(hpack.HeaderField{Name: name, Value: value})
1701
+ }
1702
+
1703
+ type resAndError struct {
1704
+ _ incomparable
1705
+ res *http.Response
1706
+ err error
1707
+ }
1708
+
1709
+ // requires cc.mu be held.
1710
+ func (cc *ClientConn) addStreamLocked(cs *clientStream) {
1711
+ cs.flow.add(int32(cc.initialWindowSize))
1712
+ cs.flow.setConnFlow(&cc.flow)
1713
+ cs.inflow.init(cc.initialStreamRecvWindowSize)
1714
+ cs.ID = cc.nextStreamID
1715
+ cc.nextStreamID += 2
1716
+ cc.streams[cs.ID] = cs
1717
+ if cs.ID == 0 {
1718
+ panic("assigned stream ID 0")
1719
+ }
1720
+ }
1721
+
1722
+ func (cc *ClientConn) forgetStreamID(id uint32) {
1723
+ cc.mu.Lock()
1724
+ slen := len(cc.streams)
1725
+ delete(cc.streams, id)
1726
+ if len(cc.streams) != slen-1 {
1727
+ panic("forgetting unknown stream id")
1728
+ }
1729
+ cc.lastActive = time.Now()
1730
+ if len(cc.streams) == 0 && cc.idleTimer != nil {
1731
+ cc.idleTimer.Reset(cc.idleTimeout)
1732
+ cc.lastIdle = time.Now()
1733
+ }
1734
+ // Wake up writeRequestBody via clientStream.awaitFlowControl and
1735
+ // wake up RoundTrip if there is a pending request.
1736
+ cc.cond.Broadcast()
1737
+
1738
+ closeOnIdle := cc.singleUse || cc.doNotReuse || cc.t.disableKeepAlives() || cc.goAway != nil
1739
+ if closeOnIdle && cc.streamsReserved == 0 && len(cc.streams) == 0 {
1740
+ if VerboseLogs {
1741
+ cc.vlogf("http2: Transport closing idle conn %p (forSingleUse=%v, maxStream=%v)", cc, cc.singleUse, cc.nextStreamID-2)
1742
+ }
1743
+ cc.closed = true
1744
+ defer cc.closeConn()
1745
+ }
1746
+
1747
+ cc.mu.Unlock()
1748
+ }
1749
+
1750
+ // clientConnReadLoop is the state owned by the clientConn's frame-reading readLoop.
1751
+ type clientConnReadLoop struct {
1752
+ _ incomparable
1753
+ cc *ClientConn
1754
+ }
1755
+
1756
+ // readLoop runs in its own goroutine and reads and dispatches frames.
1757
+ func (cc *ClientConn) readLoop() {
1758
+ rl := &clientConnReadLoop{cc: cc}
1759
+ defer rl.cleanup()
1760
+ cc.readerErr = rl.run()
1761
+ if ce, ok := cc.readerErr.(ConnectionError); ok {
1762
+ cc.wmu.Lock()
1763
+ cc.fr.WriteGoAway(0, ErrCode(ce), nil)
1764
+ cc.wmu.Unlock()
1765
+ }
1766
+ }
1767
+
1768
+ func isEOFOrNetReadError(err error) bool {
1769
+ if err == io.EOF {
1770
+ return true
1771
+ }
1772
+ ne, ok := err.(*net.OpError)
1773
+ return ok && ne.Op == "read"
1774
+ }
1775
+
1776
+ func (rl *clientConnReadLoop) cleanup() {
1777
+ cc := rl.cc
1778
+ defer cc.closeConn()
1779
+ defer close(cc.readerDone)
1780
+
1781
+ if cc.idleTimer != nil {
1782
+ cc.idleTimer.Stop()
1783
+ }
1784
+
1785
+ // Close any response bodies if the server closes prematurely.
1786
+ // TODO: also do this if we've written the headers but not
1787
+ // gotten a response yet.
1788
+ err := cc.readerErr
1789
+ cc.mu.Lock()
1790
+ if cc.goAway != nil && isEOFOrNetReadError(err) {
1791
+ err = GoAwayError{
1792
+ LastStreamID: cc.goAway.LastStreamID,
1793
+ ErrCode: cc.goAway.ErrCode,
1794
+ DebugData: cc.goAwayDebug,
1795
+ }
1796
+ } else if err == io.EOF {
1797
+ err = io.ErrUnexpectedEOF
1798
+ }
1799
+ cc.closed = true
1800
+
1801
+ // If the connection has never been used, and has been open for only a short time,
1802
+ // leave it in the connection pool for a little while.
1803
+ //
1804
+ // This avoids a situation where new connections are constantly created,
1805
+ // added to the pool, fail, and are removed from the pool, without any error
1806
+ // being surfaced to the user.
1807
+ unusedWaitTime := 5 * time.Second
1808
+ if cc.idleTimeout > 0 && unusedWaitTime > cc.idleTimeout {
1809
+ unusedWaitTime = cc.idleTimeout
1810
+ }
1811
+ idleTime := time.Now().Sub(cc.lastActive)
1812
+ if atomic.LoadUint32(&cc.atomicReused) == 0 && idleTime < unusedWaitTime && !cc.closedOnIdle {
1813
+ cc.idleTimer = time.AfterFunc(unusedWaitTime-idleTime, func() {
1814
+ cc.t.connPool().MarkDead(cc)
1815
+ })
1816
+ } else {
1817
+ cc.mu.Unlock() // avoid any deadlocks in MarkDead
1818
+ cc.t.connPool().MarkDead(cc)
1819
+ cc.mu.Lock()
1820
+ }
1821
+
1822
+ for _, cs := range cc.streams {
1823
+ select {
1824
+ case <-cs.peerClosed:
1825
+ // The server closed the stream before closing the conn,
1826
+ // so no need to interrupt it.
1827
+ default:
1828
+ cs.abortStreamLocked(err)
1829
+ }
1830
+ }
1831
+ cc.cond.Broadcast()
1832
+ cc.mu.Unlock()
1833
+
1834
+ if !cc.seenSettings {
1835
+ // If we have a pending request that wants extended CONNECT,
1836
+ // let it continue and fail with the connection error.
1837
+ cc.extendedConnectAllowed = true
1838
+ close(cc.seenSettingsChan)
1839
+ }
1840
+ }
1841
+
1842
+ // countReadFrameError calls Transport.CountError with a string
1843
+ // representing err.
1844
+ func (cc *ClientConn) countReadFrameError(err error) {
1845
+ f := cc.t.CountError
1846
+ if f == nil || err == nil {
1847
+ return
1848
+ }
1849
+ if ce, ok := err.(ConnectionError); ok {
1850
+ errCode := ErrCode(ce)
1851
+ f(fmt.Sprintf("read_frame_conn_error_%s", errCode.stringToken()))
1852
+ return
1853
+ }
1854
+ if errors.Is(err, io.EOF) {
1855
+ f("read_frame_eof")
1856
+ return
1857
+ }
1858
+ if errors.Is(err, io.ErrUnexpectedEOF) {
1859
+ f("read_frame_unexpected_eof")
1860
+ return
1861
+ }
1862
+ if errors.Is(err, ErrFrameTooLarge) {
1863
+ f("read_frame_too_large")
1864
+ return
1865
+ }
1866
+ f("read_frame_other")
1867
+ }
1868
+
1869
+ func (rl *clientConnReadLoop) run() error {
1870
+ cc := rl.cc
1871
+ gotSettings := false
1872
+ readIdleTimeout := cc.readIdleTimeout
1873
+ var t *time.Timer
1874
+ if readIdleTimeout != 0 {
1875
+ t = time.AfterFunc(readIdleTimeout, cc.healthCheck)
1876
+ }
1877
+ for {
1878
+ f, err := cc.fr.ReadFrame()
1879
+ if t != nil {
1880
+ t.Reset(readIdleTimeout)
1881
+ }
1882
+ if err != nil {
1883
+ cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err)
1884
+ }
1885
+ if se, ok := err.(StreamError); ok {
1886
+ if cs := rl.streamByID(se.StreamID, notHeaderOrDataFrame); cs != nil {
1887
+ if se.Cause == nil {
1888
+ se.Cause = cc.fr.errDetail
1889
+ }
1890
+ rl.endStreamError(cs, se)
1891
+ }
1892
+ continue
1893
+ } else if err != nil {
1894
+ cc.countReadFrameError(err)
1895
+ return err
1896
+ }
1897
+ if VerboseLogs {
1898
+ cc.vlogf("http2: Transport received %s", summarizeFrame(f))
1899
+ }
1900
+ if !gotSettings {
1901
+ if _, ok := f.(*SettingsFrame); !ok {
1902
+ cc.logf("protocol error: received %T before a SETTINGS frame", f)
1903
+ return ConnectionError(ErrCodeProtocol)
1904
+ }
1905
+ gotSettings = true
1906
+ }
1907
+
1908
+ switch f := f.(type) {
1909
+ case *MetaHeadersFrame:
1910
+ err = rl.processHeaders(f)
1911
+ case *DataFrame:
1912
+ err = rl.processData(f)
1913
+ case *GoAwayFrame:
1914
+ err = rl.processGoAway(f)
1915
+ case *RSTStreamFrame:
1916
+ err = rl.processResetStream(f)
1917
+ case *SettingsFrame:
1918
+ err = rl.processSettings(f)
1919
+ case *PushPromiseFrame:
1920
+ err = rl.processPushPromise(f)
1921
+ case *WindowUpdateFrame:
1922
+ err = rl.processWindowUpdate(f)
1923
+ case *PingFrame:
1924
+ err = rl.processPing(f)
1925
+ default:
1926
+ cc.logf("Transport: unhandled response frame type %T", f)
1927
+ }
1928
+ if err != nil {
1929
+ if VerboseLogs {
1930
+ cc.vlogf("http2: Transport conn %p received error from processing frame %v: %v", cc, summarizeFrame(f), err)
1931
+ }
1932
+ return err
1933
+ }
1934
+ }
1935
+ }
1936
+
1937
+ func (rl *clientConnReadLoop) processHeaders(f *MetaHeadersFrame) error {
1938
+ cs := rl.streamByID(f.StreamID, headerOrDataFrame)
1939
+ if cs == nil {
1940
+ // We'd get here if we canceled a request while the
1941
+ // server had its response still in flight. So if this
1942
+ // was just something we canceled, ignore it.
1943
+ return nil
1944
+ }
1945
+ if cs.readClosed {
1946
+ rl.endStreamError(cs, StreamError{
1947
+ StreamID: f.StreamID,
1948
+ Code: ErrCodeProtocol,
1949
+ Cause: errors.New("protocol error: headers after END_STREAM"),
1950
+ })
1951
+ return nil
1952
+ }
1953
+ if !cs.firstByte {
1954
+ if cs.trace != nil {
1955
+ // TODO(bradfitz): move first response byte earlier,
1956
+ // when we first read the 9 byte header, not waiting
1957
+ // until all the HEADERS+CONTINUATION frames have been
1958
+ // merged. This works for now.
1959
+ traceFirstResponseByte(cs.trace)
1960
+ }
1961
+ cs.firstByte = true
1962
+ }
1963
+ if !cs.pastHeaders {
1964
+ cs.pastHeaders = true
1965
+ } else {
1966
+ return rl.processTrailers(cs, f)
1967
+ }
1968
+
1969
+ res, err := rl.handleResponse(cs, f)
1970
+ if err != nil {
1971
+ if _, ok := err.(ConnectionError); ok {
1972
+ return err
1973
+ }
1974
+ // Any other error type is a stream error.
1975
+ rl.endStreamError(cs, StreamError{
1976
+ StreamID: f.StreamID,
1977
+ Code: ErrCodeProtocol,
1978
+ Cause: err,
1979
+ })
1980
+ return nil // return nil from process* funcs to keep conn alive
1981
+ }
1982
+ if res == nil {
1983
+ // (nil, nil) special case. See handleResponse docs.
1984
+ return nil
1985
+ }
1986
+ cs.resTrailer = &res.Trailer
1987
+ cs.res = res
1988
+ close(cs.respHeaderRecv)
1989
+ if f.StreamEnded() {
1990
+ rl.endStream(cs)
1991
+ }
1992
+ return nil
1993
+ }
1994
+
1995
+ // may return error types nil, or ConnectionError. Any other error value
1996
+ // is a StreamError of type ErrCodeProtocol. The returned error in that case
1997
+ // is the detail.
1998
+ //
1999
+ // As a special case, handleResponse may return (nil, nil) to skip the
2000
+ // frame (currently only used for 1xx responses).
2001
+ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFrame) (*http.Response, error) {
2002
+ if f.Truncated {
2003
+ return nil, errResponseHeaderListSize
2004
+ }
2005
+
2006
+ status := f.PseudoValue("status")
2007
+ if status == "" {
2008
+ return nil, errors.New("malformed response from server: missing status pseudo header")
2009
+ }
2010
+ statusCode, err := strconv.Atoi(status)
2011
+ if err != nil {
2012
+ return nil, errors.New("malformed response from server: malformed non-numeric status pseudo header")
2013
+ }
2014
+
2015
+ regularFields := f.RegularFields()
2016
+ strs := make([]string, len(regularFields))
2017
+ header := make(http.Header, len(regularFields))
2018
+ res := &http.Response{
2019
+ Proto: "HTTP/2.0",
2020
+ ProtoMajor: 2,
2021
+ Header: header,
2022
+ StatusCode: statusCode,
2023
+ Status: status + " " + http.StatusText(statusCode),
2024
+ }
2025
+ for _, hf := range regularFields {
2026
+ key := httpcommon.CanonicalHeader(hf.Name)
2027
+ if key == "Trailer" {
2028
+ t := res.Trailer
2029
+ if t == nil {
2030
+ t = make(http.Header)
2031
+ res.Trailer = t
2032
+ }
2033
+ foreachHeaderElement(hf.Value, func(v string) {
2034
+ t[httpcommon.CanonicalHeader(v)] = nil
2035
+ })
2036
+ } else {
2037
+ vv := header[key]
2038
+ if vv == nil && len(strs) > 0 {
2039
+ // More than likely this will be a single-element key.
2040
+ // Most headers aren't multi-valued.
2041
+ // Set the capacity on strs[0] to 1, so any future append
2042
+ // won't extend the slice into the other strings.
2043
+ vv, strs = strs[:1:1], strs[1:]
2044
+ vv[0] = hf.Value
2045
+ header[key] = vv
2046
+ } else {
2047
+ header[key] = append(vv, hf.Value)
2048
+ }
2049
+ }
2050
+ }
2051
+
2052
+ if statusCode >= 100 && statusCode <= 199 {
2053
+ if f.StreamEnded() {
2054
+ return nil, errors.New("1xx informational response with END_STREAM flag")
2055
+ }
2056
+ if fn := cs.get1xxTraceFunc(); fn != nil {
2057
+ // If the 1xx response is being delivered to the user,
2058
+ // then they're responsible for limiting the number
2059
+ // of responses.
2060
+ if err := fn(statusCode, textproto.MIMEHeader(header)); err != nil {
2061
+ return nil, err
2062
+ }
2063
+ } else {
2064
+ // If the user didn't examine the 1xx response, then we
2065
+ // limit the size of all 1xx headers.
2066
+ //
2067
+ // This differs a bit from the HTTP/1 implementation, which
2068
+ // limits the size of all 1xx headers plus the final response.
2069
+ // Use the larger limit of MaxHeaderListSize and
2070
+ // net/http.Transport.MaxResponseHeaderBytes.
2071
+ limit := int64(cs.cc.t.maxHeaderListSize())
2072
+ if t1 := cs.cc.t.t1; t1 != nil && t1.MaxResponseHeaderBytes > limit {
2073
+ limit = t1.MaxResponseHeaderBytes
2074
+ }
2075
+ for _, h := range f.Fields {
2076
+ cs.totalHeaderSize += int64(h.Size())
2077
+ }
2078
+ if cs.totalHeaderSize > limit {
2079
+ if VerboseLogs {
2080
+ log.Printf("http2: 1xx informational responses too large")
2081
+ }
2082
+ return nil, errors.New("header list too large")
2083
+ }
2084
+ }
2085
+ if statusCode == 100 {
2086
+ traceGot100Continue(cs.trace)
2087
+ select {
2088
+ case cs.on100 <- struct{}{}:
2089
+ default:
2090
+ }
2091
+ }
2092
+ cs.pastHeaders = false // do it all again
2093
+ return nil, nil
2094
+ }
2095
+
2096
+ res.ContentLength = -1
2097
+ if clens := res.Header["Content-Length"]; len(clens) == 1 {
2098
+ if cl, err := strconv.ParseUint(clens[0], 10, 63); err == nil {
2099
+ res.ContentLength = int64(cl)
2100
+ } else {
2101
+ // TODO: care? unlike http/1, it won't mess up our framing, so it's
2102
+ // more safe smuggling-wise to ignore.
2103
+ }
2104
+ } else if len(clens) > 1 {
2105
+ // TODO: care? unlike http/1, it won't mess up our framing, so it's
2106
+ // more safe smuggling-wise to ignore.
2107
+ } else if f.StreamEnded() && !cs.isHead {
2108
+ res.ContentLength = 0
2109
+ }
2110
+
2111
+ if cs.isHead {
2112
+ res.Body = noBody
2113
+ return res, nil
2114
+ }
2115
+
2116
+ if f.StreamEnded() {
2117
+ if res.ContentLength > 0 {
2118
+ res.Body = missingBody{}
2119
+ } else {
2120
+ res.Body = noBody
2121
+ }
2122
+ return res, nil
2123
+ }
2124
+
2125
+ cs.bufPipe.setBuffer(&dataBuffer{expected: res.ContentLength})
2126
+ cs.bytesRemain = res.ContentLength
2127
+ res.Body = transportResponseBody{cs}
2128
+
2129
+ if cs.requestedGzip && asciiEqualFold(res.Header.Get("Content-Encoding"), "gzip") {
2130
+ res.Header.Del("Content-Encoding")
2131
+ res.Header.Del("Content-Length")
2132
+ res.ContentLength = -1
2133
+ res.Body = &gzipReader{body: res.Body}
2134
+ res.Uncompressed = true
2135
+ }
2136
+ return res, nil
2137
+ }
2138
+
2139
+ func (rl *clientConnReadLoop) processTrailers(cs *clientStream, f *MetaHeadersFrame) error {
2140
+ if cs.pastTrailers {
2141
+ // Too many HEADERS frames for this stream.
2142
+ return ConnectionError(ErrCodeProtocol)
2143
+ }
2144
+ cs.pastTrailers = true
2145
+ if !f.StreamEnded() {
2146
+ // We expect that any headers for trailers also
2147
+ // has END_STREAM.
2148
+ return ConnectionError(ErrCodeProtocol)
2149
+ }
2150
+ if len(f.PseudoFields()) > 0 {
2151
+ // No pseudo header fields are defined for trailers.
2152
+ // TODO: ConnectionError might be overly harsh? Check.
2153
+ return ConnectionError(ErrCodeProtocol)
2154
+ }
2155
+
2156
+ trailer := make(http.Header)
2157
+ for _, hf := range f.RegularFields() {
2158
+ key := httpcommon.CanonicalHeader(hf.Name)
2159
+ trailer[key] = append(trailer[key], hf.Value)
2160
+ }
2161
+ cs.trailer = trailer
2162
+
2163
+ rl.endStream(cs)
2164
+ return nil
2165
+ }
2166
+
2167
+ // transportResponseBody is the concrete type of Transport.RoundTrip's
2168
+ // Response.Body. It is an io.ReadCloser.
2169
+ type transportResponseBody struct {
2170
+ cs *clientStream
2171
+ }
2172
+
2173
+ func (b transportResponseBody) Read(p []byte) (n int, err error) {
2174
+ cs := b.cs
2175
+ cc := cs.cc
2176
+
2177
+ if cs.readErr != nil {
2178
+ return 0, cs.readErr
2179
+ }
2180
+ n, err = b.cs.bufPipe.Read(p)
2181
+ if cs.bytesRemain != -1 {
2182
+ if int64(n) > cs.bytesRemain {
2183
+ n = int(cs.bytesRemain)
2184
+ if err == nil {
2185
+ err = errors.New("net/http: server replied with more than declared Content-Length; truncated")
2186
+ cs.abortStream(err)
2187
+ }
2188
+ cs.readErr = err
2189
+ return int(cs.bytesRemain), err
2190
+ }
2191
+ cs.bytesRemain -= int64(n)
2192
+ if err == io.EOF && cs.bytesRemain > 0 {
2193
+ err = io.ErrUnexpectedEOF
2194
+ cs.readErr = err
2195
+ return n, err
2196
+ }
2197
+ }
2198
+ if n == 0 {
2199
+ // No flow control tokens to send back.
2200
+ return
2201
+ }
2202
+
2203
+ cc.mu.Lock()
2204
+ connAdd := cc.inflow.add(n)
2205
+ var streamAdd int32
2206
+ if err == nil { // No need to refresh if the stream is over or failed.
2207
+ streamAdd = cs.inflow.add(n)
2208
+ }
2209
+ cc.mu.Unlock()
2210
+
2211
+ if connAdd != 0 || streamAdd != 0 {
2212
+ cc.wmu.Lock()
2213
+ defer cc.wmu.Unlock()
2214
+ if connAdd != 0 {
2215
+ cc.fr.WriteWindowUpdate(0, mustUint31(connAdd))
2216
+ }
2217
+ if streamAdd != 0 {
2218
+ cc.fr.WriteWindowUpdate(cs.ID, mustUint31(streamAdd))
2219
+ }
2220
+ cc.bw.Flush()
2221
+ }
2222
+ return
2223
+ }
2224
+
2225
+ var errClosedResponseBody = errors.New("http2: response body closed")
2226
+
2227
+ func (b transportResponseBody) Close() error {
2228
+ cs := b.cs
2229
+ cc := cs.cc
2230
+
2231
+ cs.bufPipe.BreakWithError(errClosedResponseBody)
2232
+ cs.abortStream(errClosedResponseBody)
2233
+
2234
+ unread := cs.bufPipe.Len()
2235
+ if unread > 0 {
2236
+ cc.mu.Lock()
2237
+ // Return connection-level flow control.
2238
+ connAdd := cc.inflow.add(unread)
2239
+ cc.mu.Unlock()
2240
+
2241
+ // TODO(dneil): Acquiring this mutex can block indefinitely.
2242
+ // Move flow control return to a goroutine?
2243
+ cc.wmu.Lock()
2244
+ // Return connection-level flow control.
2245
+ if connAdd > 0 {
2246
+ cc.fr.WriteWindowUpdate(0, uint32(connAdd))
2247
+ }
2248
+ cc.bw.Flush()
2249
+ cc.wmu.Unlock()
2250
+ }
2251
+
2252
+ select {
2253
+ case <-cs.donec:
2254
+ case <-cs.ctx.Done():
2255
+ // See golang/go#49366: The net/http package can cancel the
2256
+ // request context after the response body is fully read.
2257
+ // Don't treat this as an error.
2258
+ return nil
2259
+ case <-cs.reqCancel:
2260
+ return errRequestCanceled
2261
+ }
2262
+ return nil
2263
+ }
2264
+
2265
+ func (rl *clientConnReadLoop) processData(f *DataFrame) error {
2266
+ cc := rl.cc
2267
+ cs := rl.streamByID(f.StreamID, headerOrDataFrame)
2268
+ data := f.Data()
2269
+ if cs == nil {
2270
+ cc.mu.Lock()
2271
+ neverSent := cc.nextStreamID
2272
+ cc.mu.Unlock()
2273
+ if f.StreamID >= neverSent {
2274
+ // We never asked for this.
2275
+ cc.logf("http2: Transport received unsolicited DATA frame; closing connection")
2276
+ return ConnectionError(ErrCodeProtocol)
2277
+ }
2278
+ // We probably did ask for this, but canceled. Just ignore it.
2279
+ // TODO: be stricter here? only silently ignore things which
2280
+ // we canceled, but not things which were closed normally
2281
+ // by the peer? Tough without accumulating too much state.
2282
+
2283
+ // But at least return their flow control:
2284
+ if f.Length > 0 {
2285
+ cc.mu.Lock()
2286
+ ok := cc.inflow.take(f.Length)
2287
+ connAdd := cc.inflow.add(int(f.Length))
2288
+ cc.mu.Unlock()
2289
+ if !ok {
2290
+ return ConnectionError(ErrCodeFlowControl)
2291
+ }
2292
+ if connAdd > 0 {
2293
+ cc.wmu.Lock()
2294
+ cc.fr.WriteWindowUpdate(0, uint32(connAdd))
2295
+ cc.bw.Flush()
2296
+ cc.wmu.Unlock()
2297
+ }
2298
+ }
2299
+ return nil
2300
+ }
2301
+ if cs.readClosed {
2302
+ cc.logf("protocol error: received DATA after END_STREAM")
2303
+ rl.endStreamError(cs, StreamError{
2304
+ StreamID: f.StreamID,
2305
+ Code: ErrCodeProtocol,
2306
+ })
2307
+ return nil
2308
+ }
2309
+ if !cs.pastHeaders {
2310
+ cc.logf("protocol error: received DATA before a HEADERS frame")
2311
+ rl.endStreamError(cs, StreamError{
2312
+ StreamID: f.StreamID,
2313
+ Code: ErrCodeProtocol,
2314
+ })
2315
+ return nil
2316
+ }
2317
+ if f.Length > 0 {
2318
+ if cs.isHead && len(data) > 0 {
2319
+ cc.logf("protocol error: received DATA on a HEAD request")
2320
+ rl.endStreamError(cs, StreamError{
2321
+ StreamID: f.StreamID,
2322
+ Code: ErrCodeProtocol,
2323
+ })
2324
+ return nil
2325
+ }
2326
+ // Check connection-level flow control.
2327
+ cc.mu.Lock()
2328
+ if !takeInflows(&cc.inflow, &cs.inflow, f.Length) {
2329
+ cc.mu.Unlock()
2330
+ return ConnectionError(ErrCodeFlowControl)
2331
+ }
2332
+ // Return any padded flow control now, since we won't
2333
+ // refund it later on body reads.
2334
+ var refund int
2335
+ if pad := int(f.Length) - len(data); pad > 0 {
2336
+ refund += pad
2337
+ }
2338
+
2339
+ didReset := false
2340
+ var err error
2341
+ if len(data) > 0 {
2342
+ if _, err = cs.bufPipe.Write(data); err != nil {
2343
+ // Return len(data) now if the stream is already closed,
2344
+ // since data will never be read.
2345
+ didReset = true
2346
+ refund += len(data)
2347
+ }
2348
+ }
2349
+
2350
+ sendConn := cc.inflow.add(refund)
2351
+ var sendStream int32
2352
+ if !didReset {
2353
+ sendStream = cs.inflow.add(refund)
2354
+ }
2355
+ cc.mu.Unlock()
2356
+
2357
+ if sendConn > 0 || sendStream > 0 {
2358
+ cc.wmu.Lock()
2359
+ if sendConn > 0 {
2360
+ cc.fr.WriteWindowUpdate(0, uint32(sendConn))
2361
+ }
2362
+ if sendStream > 0 {
2363
+ cc.fr.WriteWindowUpdate(cs.ID, uint32(sendStream))
2364
+ }
2365
+ cc.bw.Flush()
2366
+ cc.wmu.Unlock()
2367
+ }
2368
+
2369
+ if err != nil {
2370
+ rl.endStreamError(cs, err)
2371
+ return nil
2372
+ }
2373
+ }
2374
+
2375
+ if f.StreamEnded() {
2376
+ rl.endStream(cs)
2377
+ }
2378
+ return nil
2379
+ }
2380
+
2381
+ func (rl *clientConnReadLoop) endStream(cs *clientStream) {
2382
+ // TODO: check that any declared content-length matches, like
2383
+ // server.go's (*stream).endStream method.
2384
+ if !cs.readClosed {
2385
+ cs.readClosed = true
2386
+ // Close cs.bufPipe and cs.peerClosed with cc.mu held to avoid a
2387
+ // race condition: The caller can read io.EOF from Response.Body
2388
+ // and close the body before we close cs.peerClosed, causing
2389
+ // cleanupWriteRequest to send a RST_STREAM.
2390
+ rl.cc.mu.Lock()
2391
+ defer rl.cc.mu.Unlock()
2392
+ cs.bufPipe.closeWithErrorAndCode(io.EOF, cs.copyTrailers)
2393
+ close(cs.peerClosed)
2394
+ }
2395
+ }
2396
+
2397
+ func (rl *clientConnReadLoop) endStreamError(cs *clientStream, err error) {
2398
+ cs.readAborted = true
2399
+ cs.abortStream(err)
2400
+ }
2401
+
2402
+ func (rl *clientConnReadLoop) endStreamErrorLocked(cs *clientStream, err error) {
2403
+ cs.readAborted = true
2404
+ cs.abortStreamLocked(err)
2405
+ }
2406
+
2407
+ // Constants passed to streamByID for documentation purposes.
2408
+ const (
2409
+ headerOrDataFrame = true
2410
+ notHeaderOrDataFrame = false
2411
+ )
2412
+
2413
+ // streamByID returns the stream with the given id, or nil if no stream has that id.
2414
+ // If headerOrData is true, it clears rst.StreamPingsBlocked.
2415
+ func (rl *clientConnReadLoop) streamByID(id uint32, headerOrData bool) *clientStream {
2416
+ rl.cc.mu.Lock()
2417
+ defer rl.cc.mu.Unlock()
2418
+ if headerOrData {
2419
+ // Work around an unfortunate gRPC behavior.
2420
+ // See comment on ClientConn.rstStreamPingsBlocked for details.
2421
+ rl.cc.rstStreamPingsBlocked = false
2422
+ }
2423
+ rl.cc.readBeforeStreamID = rl.cc.nextStreamID
2424
+ cs := rl.cc.streams[id]
2425
+ if cs != nil && !cs.readAborted {
2426
+ return cs
2427
+ }
2428
+ return nil
2429
+ }
2430
+
2431
+ func (cs *clientStream) copyTrailers() {
2432
+ for k, vv := range cs.trailer {
2433
+ t := cs.resTrailer
2434
+ if *t == nil {
2435
+ *t = make(http.Header)
2436
+ }
2437
+ (*t)[k] = vv
2438
+ }
2439
+ }
2440
+
2441
+ func (rl *clientConnReadLoop) processGoAway(f *GoAwayFrame) error {
2442
+ cc := rl.cc
2443
+ cc.t.connPool().MarkDead(cc)
2444
+ if f.ErrCode != 0 {
2445
+ // TODO: deal with GOAWAY more. particularly the error code
2446
+ cc.vlogf("transport got GOAWAY with error code = %v", f.ErrCode)
2447
+ if fn := cc.t.CountError; fn != nil {
2448
+ fn("recv_goaway_" + f.ErrCode.stringToken())
2449
+ }
2450
+ }
2451
+ cc.setGoAway(f)
2452
+ return nil
2453
+ }
2454
+
2455
+ func (rl *clientConnReadLoop) processSettings(f *SettingsFrame) error {
2456
+ cc := rl.cc
2457
+ // Locking both mu and wmu here allows frame encoding to read settings with only wmu held.
2458
+ // Acquiring wmu when f.IsAck() is unnecessary, but convenient and mostly harmless.
2459
+ cc.wmu.Lock()
2460
+ defer cc.wmu.Unlock()
2461
+
2462
+ if err := rl.processSettingsNoWrite(f); err != nil {
2463
+ return err
2464
+ }
2465
+ if !f.IsAck() {
2466
+ cc.fr.WriteSettingsAck()
2467
+ cc.bw.Flush()
2468
+ }
2469
+ return nil
2470
+ }
2471
+
2472
+ func (rl *clientConnReadLoop) processSettingsNoWrite(f *SettingsFrame) error {
2473
+ cc := rl.cc
2474
+ defer cc.maybeCallStateHook()
2475
+ cc.mu.Lock()
2476
+ defer cc.mu.Unlock()
2477
+
2478
+ if f.IsAck() {
2479
+ if cc.wantSettingsAck {
2480
+ cc.wantSettingsAck = false
2481
+ return nil
2482
+ }
2483
+ return ConnectionError(ErrCodeProtocol)
2484
+ }
2485
+
2486
+ var seenMaxConcurrentStreams bool
2487
+ err := f.ForeachSetting(func(s Setting) error {
2488
+ if err := s.Valid(); err != nil {
2489
+ return err
2490
+ }
2491
+ switch s.ID {
2492
+ case SettingMaxFrameSize:
2493
+ cc.maxFrameSize = s.Val
2494
+ case SettingMaxConcurrentStreams:
2495
+ cc.maxConcurrentStreams = s.Val
2496
+ seenMaxConcurrentStreams = true
2497
+ case SettingMaxHeaderListSize:
2498
+ cc.peerMaxHeaderListSize = uint64(s.Val)
2499
+ case SettingInitialWindowSize:
2500
+ // Values above the maximum flow-control
2501
+ // window size of 2^31-1 MUST be treated as a
2502
+ // connection error (Section 5.4.1) of type
2503
+ // FLOW_CONTROL_ERROR.
2504
+ if s.Val > math.MaxInt32 {
2505
+ return ConnectionError(ErrCodeFlowControl)
2506
+ }
2507
+
2508
+ // Adjust flow control of currently-open
2509
+ // frames by the difference of the old initial
2510
+ // window size and this one.
2511
+ delta := int32(s.Val) - int32(cc.initialWindowSize)
2512
+ for _, cs := range cc.streams {
2513
+ cs.flow.add(delta)
2514
+ }
2515
+ cc.cond.Broadcast()
2516
+
2517
+ cc.initialWindowSize = s.Val
2518
+ case SettingHeaderTableSize:
2519
+ cc.henc.SetMaxDynamicTableSize(s.Val)
2520
+ cc.peerMaxHeaderTableSize = s.Val
2521
+ case SettingEnableConnectProtocol:
2522
+ // If the peer wants to send us SETTINGS_ENABLE_CONNECT_PROTOCOL,
2523
+ // we require that it do so in the first SETTINGS frame.
2524
+ //
2525
+ // When we attempt to use extended CONNECT, we wait for the first
2526
+ // SETTINGS frame to see if the server supports it. If we let the
2527
+ // server enable the feature with a later SETTINGS frame, then
2528
+ // users will see inconsistent results depending on whether we've
2529
+ // seen that frame or not.
2530
+ if !cc.seenSettings {
2531
+ cc.extendedConnectAllowed = s.Val == 1
2532
+ }
2533
+ default:
2534
+ cc.vlogf("Unhandled Setting: %v", s)
2535
+ }
2536
+ return nil
2537
+ })
2538
+ if err != nil {
2539
+ return err
2540
+ }
2541
+
2542
+ if !cc.seenSettings {
2543
+ if !seenMaxConcurrentStreams {
2544
+ // This was the servers initial SETTINGS frame and it
2545
+ // didn't contain a MAX_CONCURRENT_STREAMS field so
2546
+ // increase the number of concurrent streams this
2547
+ // connection can establish to our default.
2548
+ cc.maxConcurrentStreams = defaultMaxConcurrentStreams
2549
+ }
2550
+ close(cc.seenSettingsChan)
2551
+ cc.seenSettings = true
2552
+ }
2553
+
2554
+ return nil
2555
+ }
2556
+
2557
+ func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error {
2558
+ cc := rl.cc
2559
+ cs := rl.streamByID(f.StreamID, notHeaderOrDataFrame)
2560
+ if f.StreamID != 0 && cs == nil {
2561
+ return nil
2562
+ }
2563
+
2564
+ cc.mu.Lock()
2565
+ defer cc.mu.Unlock()
2566
+
2567
+ fl := &cc.flow
2568
+ if cs != nil {
2569
+ fl = &cs.flow
2570
+ }
2571
+ if !fl.add(int32(f.Increment)) {
2572
+ // For stream, the sender sends RST_STREAM with an error code of FLOW_CONTROL_ERROR
2573
+ if cs != nil {
2574
+ rl.endStreamErrorLocked(cs, StreamError{
2575
+ StreamID: f.StreamID,
2576
+ Code: ErrCodeFlowControl,
2577
+ })
2578
+ return nil
2579
+ }
2580
+
2581
+ return ConnectionError(ErrCodeFlowControl)
2582
+ }
2583
+ cc.cond.Broadcast()
2584
+ return nil
2585
+ }
2586
+
2587
+ func (rl *clientConnReadLoop) processResetStream(f *RSTStreamFrame) error {
2588
+ cs := rl.streamByID(f.StreamID, notHeaderOrDataFrame)
2589
+ if cs == nil {
2590
+ // TODO: return error if server tries to RST_STREAM an idle stream
2591
+ return nil
2592
+ }
2593
+ serr := streamError(cs.ID, f.ErrCode)
2594
+ serr.Cause = errFromPeer
2595
+ if f.ErrCode == ErrCodeProtocol {
2596
+ rl.cc.SetDoNotReuse()
2597
+ }
2598
+ if fn := cs.cc.t.CountError; fn != nil {
2599
+ fn("recv_rststream_" + f.ErrCode.stringToken())
2600
+ }
2601
+ cs.abortStream(serr)
2602
+
2603
+ cs.bufPipe.CloseWithError(serr)
2604
+ return nil
2605
+ }
2606
+
2607
+ // Ping sends a PING frame to the server and waits for the ack.
2608
+ func (cc *ClientConn) ping(ctx context.Context) error {
2609
+ c := make(chan struct{})
2610
+ // Generate a random payload
2611
+ var p [8]byte
2612
+ for {
2613
+ if _, err := rand.Read(p[:]); err != nil {
2614
+ return err
2615
+ }
2616
+ cc.mu.Lock()
2617
+ // check for dup before insert
2618
+ if _, found := cc.pings[p]; !found {
2619
+ cc.pings[p] = c
2620
+ cc.mu.Unlock()
2621
+ break
2622
+ }
2623
+ cc.mu.Unlock()
2624
+ }
2625
+ var pingError error
2626
+ errc := make(chan struct{})
2627
+ go func() {
2628
+ cc.wmu.Lock()
2629
+ defer cc.wmu.Unlock()
2630
+ if pingError = cc.fr.WritePing(false, p); pingError != nil {
2631
+ close(errc)
2632
+ return
2633
+ }
2634
+ if pingError = cc.bw.Flush(); pingError != nil {
2635
+ close(errc)
2636
+ return
2637
+ }
2638
+ }()
2639
+ select {
2640
+ case <-c:
2641
+ return nil
2642
+ case <-errc:
2643
+ return pingError
2644
+ case <-ctx.Done():
2645
+ return ctx.Err()
2646
+ case <-cc.readerDone:
2647
+ // connection closed
2648
+ return cc.readerErr
2649
+ }
2650
+ }
2651
+
2652
+ func (rl *clientConnReadLoop) processPing(f *PingFrame) error {
2653
+ if f.IsAck() {
2654
+ cc := rl.cc
2655
+ defer cc.maybeCallStateHook()
2656
+ cc.mu.Lock()
2657
+ defer cc.mu.Unlock()
2658
+ // If ack, notify listener if any
2659
+ if c, ok := cc.pings[f.Data]; ok {
2660
+ close(c)
2661
+ delete(cc.pings, f.Data)
2662
+ }
2663
+ if cc.pendingResets > 0 {
2664
+ // See clientStream.cleanupWriteRequest.
2665
+ cc.pendingResets = 0
2666
+ cc.rstStreamPingsBlocked = true
2667
+ cc.cond.Broadcast()
2668
+ }
2669
+ return nil
2670
+ }
2671
+ cc := rl.cc
2672
+ cc.wmu.Lock()
2673
+ defer cc.wmu.Unlock()
2674
+ if err := cc.fr.WritePing(true, f.Data); err != nil {
2675
+ return err
2676
+ }
2677
+ return cc.bw.Flush()
2678
+ }
2679
+
2680
+ func (rl *clientConnReadLoop) processPushPromise(f *PushPromiseFrame) error {
2681
+ // We told the peer we don't want them.
2682
+ // Spec says:
2683
+ // "PUSH_PROMISE MUST NOT be sent if the SETTINGS_ENABLE_PUSH
2684
+ // setting of the peer endpoint is set to 0. An endpoint that
2685
+ // has set this setting and has received acknowledgement MUST
2686
+ // treat the receipt of a PUSH_PROMISE frame as a connection
2687
+ // error (Section 5.4.1) of type PROTOCOL_ERROR."
2688
+ return ConnectionError(ErrCodeProtocol)
2689
+ }
2690
+
2691
+ // writeStreamReset sends a RST_STREAM frame.
2692
+ // When ping is true, it also sends a PING frame with a random payload.
2693
+ func (cc *ClientConn) writeStreamReset(streamID uint32, code ErrCode, ping bool, err error) {
2694
+ // TODO: map err to more interesting error codes, once the
2695
+ // HTTP community comes up with some. But currently for
2696
+ // RST_STREAM there's no equivalent to GOAWAY frame's debug
2697
+ // data, and the error codes are all pretty vague ("cancel").
2698
+ cc.wmu.Lock()
2699
+ cc.fr.WriteRSTStream(streamID, code)
2700
+ if ping {
2701
+ var payload [8]byte
2702
+ rand.Read(payload[:])
2703
+ cc.fr.WritePing(false, payload)
2704
+ }
2705
+ cc.bw.Flush()
2706
+ cc.wmu.Unlock()
2707
+ }
2708
+
2709
+ var (
2710
+ errResponseHeaderListSize = errors.New("http2: response header list larger than advertised limit")
2711
+ errRequestHeaderListSize = httpcommon.ErrRequestHeaderListSize
2712
+ )
2713
+
2714
+ func (cc *ClientConn) logf(format string, args ...interface{}) {
2715
+ cc.t.logf(format, args...)
2716
+ }
2717
+
2718
+ func (cc *ClientConn) vlogf(format string, args ...interface{}) {
2719
+ cc.t.vlogf(format, args...)
2720
+ }
2721
+
2722
+ var noBody io.ReadCloser = noBodyReader{}
2723
+
2724
+ type noBodyReader struct{}
2725
+
2726
+ func (noBodyReader) Close() error { return nil }
2727
+ func (noBodyReader) Read([]byte) (int, error) { return 0, io.EOF }
2728
+
2729
+ type missingBody struct{}
2730
+
2731
+ func (missingBody) Close() error { return nil }
2732
+ func (missingBody) Read([]byte) (int, error) { return 0, io.ErrUnexpectedEOF }
2733
+
2734
+ func strSliceContains(ss []string, s string) bool {
2735
+ for _, v := range ss {
2736
+ if v == s {
2737
+ return true
2738
+ }
2739
+ }
2740
+ return false
2741
+ }
2742
+
2743
+ type erringRoundTripper struct{ err error }
2744
+
2745
+ func (rt erringRoundTripper) RoundTripErr() error { return rt.err }
2746
+ func (rt erringRoundTripper) RoundTrip(*http.Request) (*http.Response, error) { return nil, rt.err }
2747
+
2748
+ var errConcurrentReadOnResBody = errors.New("http2: concurrent read on response body")
2749
+
2750
+ // gzipReader wraps a response body so it can lazily
2751
+ // get gzip.Reader from the pool on the first call to Read.
2752
+ // After Close is called it puts gzip.Reader to the pool immediately
2753
+ // if there is no Read in progress or later when Read completes.
2754
+ type gzipReader struct {
2755
+ _ incomparable
2756
+ body io.ReadCloser // underlying Response.Body
2757
+ mu sync.Mutex // guards zr and zerr
2758
+ zr *gzip.Reader // stores gzip reader from the pool between reads
2759
+ zerr error // sticky gzip reader init error or sentinel value to detect concurrent read and read after close
2760
+ }
2761
+
2762
+ type eofReader struct{}
2763
+
2764
+ func (eofReader) Read([]byte) (int, error) { return 0, io.EOF }
2765
+ func (eofReader) ReadByte() (byte, error) { return 0, io.EOF }
2766
+
2767
+ var gzipPool = sync.Pool{New: func() any { return new(gzip.Reader) }}
2768
+
2769
+ // gzipPoolGet gets a gzip.Reader from the pool and resets it to read from r.
2770
+ func gzipPoolGet(r io.Reader) (*gzip.Reader, error) {
2771
+ zr := gzipPool.Get().(*gzip.Reader)
2772
+ if err := zr.Reset(r); err != nil {
2773
+ gzipPoolPut(zr)
2774
+ return nil, err
2775
+ }
2776
+ return zr, nil
2777
+ }
2778
+
2779
+ // gzipPoolPut puts a gzip.Reader back into the pool.
2780
+ func gzipPoolPut(zr *gzip.Reader) {
2781
+ // Reset will allocate bufio.Reader if we pass it anything
2782
+ // other than a flate.Reader, so ensure that it's getting one.
2783
+ var r flate.Reader = eofReader{}
2784
+ zr.Reset(r)
2785
+ gzipPool.Put(zr)
2786
+ }
2787
+
2788
+ // acquire returns a gzip.Reader for reading response body.
2789
+ // The reader must be released after use.
2790
+ func (gz *gzipReader) acquire() (*gzip.Reader, error) {
2791
+ gz.mu.Lock()
2792
+ defer gz.mu.Unlock()
2793
+ if gz.zerr != nil {
2794
+ return nil, gz.zerr
2795
+ }
2796
+ if gz.zr == nil {
2797
+ gz.zr, gz.zerr = gzipPoolGet(gz.body)
2798
+ if gz.zerr != nil {
2799
+ return nil, gz.zerr
2800
+ }
2801
+ }
2802
+ ret := gz.zr
2803
+ gz.zr, gz.zerr = nil, errConcurrentReadOnResBody
2804
+ return ret, nil
2805
+ }
2806
+
2807
+ // release returns the gzip.Reader to the pool if Close was called during Read.
2808
+ func (gz *gzipReader) release(zr *gzip.Reader) {
2809
+ gz.mu.Lock()
2810
+ defer gz.mu.Unlock()
2811
+ if gz.zerr == errConcurrentReadOnResBody {
2812
+ gz.zr, gz.zerr = zr, nil
2813
+ } else { // fs.ErrClosed
2814
+ gzipPoolPut(zr)
2815
+ }
2816
+ }
2817
+
2818
+ // close returns the gzip.Reader to the pool immediately or
2819
+ // signals release to do so after Read completes.
2820
+ func (gz *gzipReader) close() {
2821
+ gz.mu.Lock()
2822
+ defer gz.mu.Unlock()
2823
+ if gz.zerr == nil && gz.zr != nil {
2824
+ gzipPoolPut(gz.zr)
2825
+ gz.zr = nil
2826
+ }
2827
+ gz.zerr = fs.ErrClosed
2828
+ }
2829
+
2830
+ func (gz *gzipReader) Read(p []byte) (n int, err error) {
2831
+ zr, err := gz.acquire()
2832
+ if err != nil {
2833
+ return 0, err
2834
+ }
2835
+ defer gz.release(zr)
2836
+
2837
+ return zr.Read(p)
2838
+ }
2839
+
2840
+ func (gz *gzipReader) Close() error {
2841
+ gz.close()
2842
+
2843
+ return gz.body.Close()
2844
+ }
2845
+
2846
+ // isConnectionCloseRequest reports whether req should use its own
2847
+ // connection for a single request and then close the connection.
2848
+ func isConnectionCloseRequest(req *http.Request) bool {
2849
+ return req.Close || httpguts.HeaderValuesContainsToken(req.Header["Connection"], "close")
2850
+ }
2851
+
2852
+ // registerHTTPSProtocol calls Transport.RegisterProtocol but
2853
+ // converting panics into errors.
2854
+ func registerHTTPSProtocol(t *http.Transport, rt noDialH2RoundTripper) (err error) {
2855
+ defer func() {
2856
+ if e := recover(); e != nil {
2857
+ err = fmt.Errorf("%v", e)
2858
+ }
2859
+ }()
2860
+ t.RegisterProtocol("https", rt)
2861
+ return nil
2862
+ }
2863
+
2864
+ // noDialH2RoundTripper is a RoundTripper which only tries to complete the request
2865
+ // if there's already a cached connection to the host.
2866
+ // (The field is exported so it can be accessed via reflect from net/http; tested
2867
+ // by TestNoDialH2RoundTripperType)
2868
+ //
2869
+ // A noDialH2RoundTripper is registered with http1.Transport.RegisterProtocol,
2870
+ // and the http1.Transport can use type assertions to call non-RoundTrip methods on it.
2871
+ // This lets us expose, for example, NewClientConn to net/http.
2872
+ type noDialH2RoundTripper struct{ *Transport }
2873
+
2874
+ func (rt noDialH2RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
2875
+ res, err := rt.Transport.RoundTrip(req)
2876
+ if isNoCachedConnError(err) {
2877
+ return nil, http.ErrSkipAltProtocol
2878
+ }
2879
+ return res, err
2880
+ }
2881
+
2882
+ func (rt noDialH2RoundTripper) NewClientConn(conn net.Conn, internalStateHook func()) (http.RoundTripper, error) {
2883
+ tr := rt.Transport
2884
+ cc, err := tr.newClientConn(conn, tr.disableKeepAlives(), internalStateHook)
2885
+ if err != nil {
2886
+ return nil, err
2887
+ }
2888
+
2889
+ // RoundTrip should block when the conn is at its concurrency limit,
2890
+ // not return an error. Setting strictMaxConcurrentStreams enables this.
2891
+ cc.strictMaxConcurrentStreams = true
2892
+
2893
+ return netHTTPClientConn{cc}, nil
2894
+ }
2895
+
2896
+ // netHTTPClientConn wraps ClientConn and implements the interface net/http expects from
2897
+ // the RoundTripper returned by NewClientConn.
2898
+ type netHTTPClientConn struct {
2899
+ cc *ClientConn
2900
+ }
2901
+
2902
+ func (cc netHTTPClientConn) RoundTrip(req *http.Request) (*http.Response, error) {
2903
+ return cc.cc.RoundTrip(req)
2904
+ }
2905
+
2906
+ func (cc netHTTPClientConn) Close() error {
2907
+ return cc.cc.Close()
2908
+ }
2909
+
2910
+ func (cc netHTTPClientConn) Err() error {
2911
+ cc.cc.mu.Lock()
2912
+ defer cc.cc.mu.Unlock()
2913
+ if cc.cc.closed {
2914
+ return errors.New("connection closed")
2915
+ }
2916
+ return nil
2917
+ }
2918
+
2919
+ func (cc netHTTPClientConn) Reserve() error {
2920
+ defer cc.cc.maybeCallStateHook()
2921
+ cc.cc.mu.Lock()
2922
+ defer cc.cc.mu.Unlock()
2923
+ if !cc.cc.canReserveLocked() {
2924
+ return errors.New("connection is unavailable")
2925
+ }
2926
+ cc.cc.streamsReserved++
2927
+ return nil
2928
+ }
2929
+
2930
+ func (cc netHTTPClientConn) Release() {
2931
+ defer cc.cc.maybeCallStateHook()
2932
+ cc.cc.mu.Lock()
2933
+ defer cc.cc.mu.Unlock()
2934
+ // We don't complain if streamsReserved is 0.
2935
+ //
2936
+ // This is consistent with RoundTrip: both Release and RoundTrip will
2937
+ // consume a reservation iff one exists.
2938
+ if cc.cc.streamsReserved > 0 {
2939
+ cc.cc.streamsReserved--
2940
+ }
2941
+ }
2942
+
2943
+ func (cc netHTTPClientConn) Available() int {
2944
+ cc.cc.mu.Lock()
2945
+ defer cc.cc.mu.Unlock()
2946
+ return cc.cc.availableLocked()
2947
+ }
2948
+
2949
+ func (cc netHTTPClientConn) InFlight() int {
2950
+ cc.cc.mu.Lock()
2951
+ defer cc.cc.mu.Unlock()
2952
+ return cc.cc.currentRequestCountLocked()
2953
+ }
2954
+
2955
+ func (cc *ClientConn) maybeCallStateHook() {
2956
+ if cc.internalStateHook != nil {
2957
+ cc.internalStateHook()
2958
+ }
2959
+ }
2960
+
2961
+ func (t *Transport) idleConnTimeout() time.Duration {
2962
+ // to keep things backwards compatible, we use non-zero values of
2963
+ // IdleConnTimeout, followed by using the IdleConnTimeout on the underlying
2964
+ // http1 transport, followed by 0
2965
+ if t.IdleConnTimeout != 0 {
2966
+ return t.IdleConnTimeout
2967
+ }
2968
+
2969
+ if t.t1 != nil {
2970
+ return t.t1.IdleConnTimeout
2971
+ }
2972
+
2973
+ return 0
2974
+ }
2975
+
2976
+ func traceGetConn(req *http.Request, hostPort string) {
2977
+ trace := httptrace.ContextClientTrace(req.Context())
2978
+ if trace == nil || trace.GetConn == nil {
2979
+ return
2980
+ }
2981
+ trace.GetConn(hostPort)
2982
+ }
2983
+
2984
+ func traceGotConn(req *http.Request, cc *ClientConn, reused bool) {
2985
+ trace := httptrace.ContextClientTrace(req.Context())
2986
+ if trace == nil || trace.GotConn == nil {
2987
+ return
2988
+ }
2989
+ ci := httptrace.GotConnInfo{Conn: cc.tconn}
2990
+ ci.Reused = reused
2991
+ cc.mu.Lock()
2992
+ ci.WasIdle = len(cc.streams) == 0 && reused
2993
+ if ci.WasIdle && !cc.lastActive.IsZero() {
2994
+ ci.IdleTime = time.Since(cc.lastActive)
2995
+ }
2996
+ cc.mu.Unlock()
2997
+
2998
+ trace.GotConn(ci)
2999
+ }
3000
+
3001
+ func traceWroteHeaders(trace *httptrace.ClientTrace) {
3002
+ if trace != nil && trace.WroteHeaders != nil {
3003
+ trace.WroteHeaders()
3004
+ }
3005
+ }
3006
+
3007
+ func traceGot100Continue(trace *httptrace.ClientTrace) {
3008
+ if trace != nil && trace.Got100Continue != nil {
3009
+ trace.Got100Continue()
3010
+ }
3011
+ }
3012
+
3013
+ func traceWait100Continue(trace *httptrace.ClientTrace) {
3014
+ if trace != nil && trace.Wait100Continue != nil {
3015
+ trace.Wait100Continue()
3016
+ }
3017
+ }
3018
+
3019
+ func traceWroteRequest(trace *httptrace.ClientTrace, err error) {
3020
+ if trace != nil && trace.WroteRequest != nil {
3021
+ trace.WroteRequest(httptrace.WroteRequestInfo{Err: err})
3022
+ }
3023
+ }
3024
+
3025
+ func traceFirstResponseByte(trace *httptrace.ClientTrace) {
3026
+ if trace != nil && trace.GotFirstResponseByte != nil {
3027
+ trace.GotFirstResponseByte()
3028
+ }
3029
+ }
3030
+
3031
+ func traceGot1xxResponseFunc(trace *httptrace.ClientTrace) func(int, textproto.MIMEHeader) error {
3032
+ if trace != nil {
3033
+ return trace.Got1xxResponse
3034
+ }
3035
+ return nil
3036
+ }