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,3217 @@
1
+ // Copyright 2014 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
+ // TODO: turn off the serve goroutine when idle, so
8
+ // an idle conn only has the readFrames goroutine active. (which could
9
+ // also be optimized probably to pin less memory in crypto/tls). This
10
+ // would involve tracking when the serve goroutine is active (atomic
11
+ // int32 read/CAS probably?) and starting it up when frames arrive,
12
+ // and shutting it down when all handlers exit. the occasional PING
13
+ // packets could use time.AfterFunc to call sc.wakeStartServeLoop()
14
+ // (which is a no-op if already running) and then queue the PING write
15
+ // as normal. The serve loop would then exit in most cases (if no
16
+ // Handlers running) and not be woken up again until the PING packet
17
+ // returns.
18
+
19
+ // TODO (maybe): add a mechanism for Handlers to going into
20
+ // half-closed-local mode (rw.(io.Closer) test?) but not exit their
21
+ // handler, and continue to be able to read from the
22
+ // Request.Body. This would be a somewhat semantic change from HTTP/1
23
+ // (or at least what we expose in net/http), so I'd probably want to
24
+ // add it there too. For now, this package says that returning from
25
+ // the Handler ServeHTTP function means you're both done reading and
26
+ // done writing, without a way to stop just one or the other.
27
+
28
+ package http2
29
+
30
+ import (
31
+ "bufio"
32
+ "bytes"
33
+ "context"
34
+ "crypto/rand"
35
+ "crypto/tls"
36
+ "errors"
37
+ "fmt"
38
+ "io"
39
+ "log"
40
+ "math"
41
+ "net"
42
+ "net/http"
43
+ "net/textproto"
44
+ "net/url"
45
+ "os"
46
+ "reflect"
47
+ "runtime"
48
+ "strconv"
49
+ "strings"
50
+ "sync"
51
+ "time"
52
+
53
+ "golang.org/x/net/http/httpguts"
54
+ "golang.org/x/net/http2/hpack"
55
+ "golang.org/x/net/internal/httpcommon"
56
+ )
57
+
58
+ const (
59
+ prefaceTimeout = 10 * time.Second
60
+ firstSettingsTimeout = 2 * time.Second // should be in-flight with preface anyway
61
+ handlerChunkWriteSize = 4 << 10
62
+ defaultMaxStreams = 250 // TODO: make this 100 as the GFE seems to?
63
+
64
+ // maxQueuedControlFrames is the maximum number of control frames like
65
+ // SETTINGS, PING and RST_STREAM that will be queued for writing before
66
+ // the connection is closed to prevent memory exhaustion attacks.
67
+ maxQueuedControlFrames = 10000
68
+ )
69
+
70
+ var (
71
+ errClientDisconnected = errors.New("client disconnected")
72
+ errClosedBody = errors.New("body closed by handler")
73
+ errHandlerComplete = errors.New("http2: request body closed due to handler exiting")
74
+ errStreamClosed = errors.New("http2: stream closed")
75
+ )
76
+
77
+ var responseWriterStatePool = sync.Pool{
78
+ New: func() interface{} {
79
+ rws := &responseWriterState{}
80
+ rws.bw = bufio.NewWriterSize(chunkWriter{rws}, handlerChunkWriteSize)
81
+ return rws
82
+ },
83
+ }
84
+
85
+ // Test hooks.
86
+ var (
87
+ testHookOnConn func()
88
+ testHookGetServerConn func(*serverConn)
89
+ testHookOnPanicMu *sync.Mutex // nil except in tests
90
+ testHookOnPanic func(sc *serverConn, panicVal interface{}) (rePanic bool)
91
+ )
92
+
93
+ type serverInternalState struct {
94
+ mu sync.Mutex
95
+ activeConns map[*serverConn]struct{}
96
+
97
+ // Pool of error channels. This is per-Server rather than global
98
+ // because channels can't be reused across synctest bubbles.
99
+ errChanPool sync.Pool
100
+
101
+ // Used in tests.
102
+ testNewConn func(*serverConn)
103
+ }
104
+
105
+ func (s *serverInternalState) registerConn(sc *serverConn) {
106
+ if s == nil {
107
+ return // if the Server was used without calling ConfigureServer
108
+ }
109
+ s.mu.Lock()
110
+ s.activeConns[sc] = struct{}{}
111
+ s.mu.Unlock()
112
+ }
113
+
114
+ func (s *serverInternalState) unregisterConn(sc *serverConn) {
115
+ if s == nil {
116
+ return // if the Server was used without calling ConfigureServer
117
+ }
118
+ s.mu.Lock()
119
+ delete(s.activeConns, sc)
120
+ s.mu.Unlock()
121
+ }
122
+
123
+ func (s *serverInternalState) startGracefulShutdown() {
124
+ if s == nil {
125
+ return // if the Server was used without calling ConfigureServer
126
+ }
127
+ s.mu.Lock()
128
+ for sc := range s.activeConns {
129
+ sc.startGracefulShutdown()
130
+ }
131
+ s.mu.Unlock()
132
+ }
133
+
134
+ // Global error channel pool used for uninitialized Servers.
135
+ // We use a per-Server pool when possible to avoid using channels across synctest bubbles.
136
+ var errChanPool = sync.Pool{
137
+ New: func() any { return make(chan error, 1) },
138
+ }
139
+
140
+ func (s *serverInternalState) getErrChan() chan error {
141
+ if s == nil {
142
+ return errChanPool.Get().(chan error) // Server used without calling ConfigureServer
143
+ }
144
+ return s.errChanPool.Get().(chan error)
145
+ }
146
+
147
+ func (s *serverInternalState) putErrChan(ch chan error) {
148
+ if s == nil {
149
+ errChanPool.Put(ch) // Server used without calling ConfigureServer
150
+ return
151
+ }
152
+ s.errChanPool.Put(ch)
153
+ }
154
+
155
+ func configureServer(s *http.Server, conf *Server) error {
156
+ if s == nil {
157
+ panic("nil *http.Server")
158
+ }
159
+ if conf == nil {
160
+ conf = new(Server)
161
+ }
162
+ conf.state = &serverInternalState{
163
+ activeConns: make(map[*serverConn]struct{}),
164
+ errChanPool: sync.Pool{New: func() any { return make(chan error, 1) }},
165
+ }
166
+ if h1, h2 := s, conf; h2.IdleTimeout == 0 {
167
+ if h1.IdleTimeout != 0 {
168
+ h2.IdleTimeout = h1.IdleTimeout
169
+ } else {
170
+ h2.IdleTimeout = h1.ReadTimeout
171
+ }
172
+ }
173
+ s.RegisterOnShutdown(conf.state.startGracefulShutdown)
174
+
175
+ if s.TLSConfig == nil {
176
+ s.TLSConfig = new(tls.Config)
177
+ } else if s.TLSConfig.CipherSuites != nil && s.TLSConfig.MinVersion < tls.VersionTLS13 {
178
+ // If they already provided a TLS 1.0–1.2 CipherSuite list, return an
179
+ // error if it is missing ECDHE_RSA_WITH_AES_128_GCM_SHA256 or
180
+ // ECDHE_ECDSA_WITH_AES_128_GCM_SHA256.
181
+ haveRequired := false
182
+ for _, cs := range s.TLSConfig.CipherSuites {
183
+ switch cs {
184
+ case tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
185
+ // Alternative MTI cipher to not discourage ECDSA-only servers.
186
+ // See http://golang.org/cl/30721 for further information.
187
+ tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:
188
+ haveRequired = true
189
+ }
190
+ }
191
+ if !haveRequired {
192
+ return fmt.Errorf("http2: TLSConfig.CipherSuites is missing an HTTP/2-required AES_128_GCM_SHA256 cipher (need at least one of TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 or TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256)")
193
+ }
194
+ }
195
+
196
+ // Note: not setting MinVersion to tls.VersionTLS12,
197
+ // as we don't want to interfere with HTTP/1.1 traffic
198
+ // on the user's server. We enforce TLS 1.2 later once
199
+ // we accept a connection. Ideally this should be done
200
+ // during next-proto selection, but using TLS <1.2 with
201
+ // HTTP/2 is still the client's bug.
202
+
203
+ s.TLSConfig.PreferServerCipherSuites = true
204
+
205
+ if !strSliceContains(s.TLSConfig.NextProtos, NextProtoTLS) {
206
+ s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, NextProtoTLS)
207
+ }
208
+ if !strSliceContains(s.TLSConfig.NextProtos, "http/1.1") {
209
+ s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, "http/1.1")
210
+ }
211
+
212
+ if s.TLSNextProto == nil {
213
+ s.TLSNextProto = map[string]func(*http.Server, *tls.Conn, http.Handler){}
214
+ }
215
+ protoHandler := func(hs *http.Server, c net.Conn, h http.Handler, sawClientPreface bool) {
216
+ if testHookOnConn != nil {
217
+ testHookOnConn()
218
+ }
219
+ // The TLSNextProto interface predates contexts, so
220
+ // the net/http package passes down its per-connection
221
+ // base context via an exported but unadvertised
222
+ // method on the Handler. This is for internal
223
+ // net/http<=>http2 use only.
224
+ var ctx context.Context
225
+ type baseContexter interface {
226
+ BaseContext() context.Context
227
+ }
228
+ if bc, ok := h.(baseContexter); ok {
229
+ ctx = bc.BaseContext()
230
+ }
231
+ conf.ServeConn(c, &ServeConnOpts{
232
+ Context: ctx,
233
+ Handler: h,
234
+ BaseConfig: hs,
235
+ SawClientPreface: sawClientPreface,
236
+ })
237
+ }
238
+ s.TLSNextProto[NextProtoTLS] = func(hs *http.Server, c *tls.Conn, h http.Handler) {
239
+ protoHandler(hs, c, h, false)
240
+ }
241
+ // The "unencrypted_http2" TLSNextProto key is used to pass off non-TLS HTTP/2 conns.
242
+ //
243
+ // A connection passed in this method has already had the HTTP/2 preface read from it.
244
+ s.TLSNextProto[nextProtoUnencryptedHTTP2] = func(hs *http.Server, c *tls.Conn, h http.Handler) {
245
+ nc, err := unencryptedNetConnFromTLSConn(c)
246
+ if err != nil {
247
+ if lg := hs.ErrorLog; lg != nil {
248
+ lg.Print(err)
249
+ } else {
250
+ log.Print(err)
251
+ }
252
+ go c.Close()
253
+ return
254
+ }
255
+ protoHandler(hs, nc, h, true)
256
+ }
257
+ return nil
258
+ }
259
+
260
+ func (s *Server) serveConn(c net.Conn, opts *ServeConnOpts, newf func(*serverConn)) {
261
+ baseCtx, cancel := serverConnBaseContext(c, opts)
262
+ defer cancel()
263
+
264
+ http1srv := opts.baseConfig()
265
+ conf := configFromServer(http1srv, s)
266
+ sc := &serverConn{
267
+ srv: s,
268
+ hs: http1srv,
269
+ conn: c,
270
+ baseCtx: baseCtx,
271
+ remoteAddrStr: c.RemoteAddr().String(),
272
+ bw: newBufferedWriter(c, conf.WriteByteTimeout),
273
+ handler: opts.handler(),
274
+ streams: make(map[uint32]*stream),
275
+ readFrameCh: make(chan readFrameResult),
276
+ wantWriteFrameCh: make(chan FrameWriteRequest, 8),
277
+ serveMsgCh: make(chan interface{}, 8),
278
+ wroteFrameCh: make(chan frameWriteResult, 1), // buffered; one send in writeFrameAsync
279
+ bodyReadCh: make(chan bodyReadMsg), // buffering doesn't matter either way
280
+ doneServing: make(chan struct{}),
281
+ clientMaxStreams: math.MaxUint32, // Section 6.5.2: "Initially, there is no limit to this value"
282
+ advMaxStreams: conf.MaxConcurrentStreams,
283
+ initialStreamSendWindowSize: initialWindowSize,
284
+ initialStreamRecvWindowSize: conf.MaxUploadBufferPerStream,
285
+ maxFrameSize: initialMaxFrameSize,
286
+ pingTimeout: conf.PingTimeout,
287
+ countErrorFunc: conf.CountError,
288
+ serveG: newGoroutineLock(),
289
+ pushEnabled: true,
290
+ sawClientPreface: opts.SawClientPreface,
291
+ }
292
+ if newf != nil {
293
+ newf(sc)
294
+ }
295
+ if s.state != nil && s.state.testNewConn != nil {
296
+ s.state.testNewConn(sc)
297
+ }
298
+
299
+ s.state.registerConn(sc)
300
+ defer s.state.unregisterConn(sc)
301
+
302
+ // The net/http package sets the write deadline from the
303
+ // http.Server.WriteTimeout during the TLS handshake, but then
304
+ // passes the connection off to us with the deadline already set.
305
+ // Write deadlines are set per stream in serverConn.newStream.
306
+ // Disarm the net.Conn write deadline here.
307
+ if sc.hs.WriteTimeout > 0 {
308
+ sc.conn.SetWriteDeadline(time.Time{})
309
+ }
310
+
311
+ switch {
312
+ case s.NewWriteScheduler != nil:
313
+ sc.writeSched = s.NewWriteScheduler()
314
+ case clientPriorityDisabled(http1srv):
315
+ sc.writeSched = newRoundRobinWriteScheduler()
316
+ default:
317
+ sc.writeSched = newPriorityWriteSchedulerRFC9218()
318
+ }
319
+
320
+ // These start at the RFC-specified defaults. If there is a higher
321
+ // configured value for inflow, that will be updated when we send a
322
+ // WINDOW_UPDATE shortly after sending SETTINGS.
323
+ sc.flow.add(initialWindowSize)
324
+ sc.inflow.init(initialWindowSize)
325
+ sc.hpackEncoder = hpack.NewEncoder(&sc.headerWriteBuf)
326
+ sc.hpackEncoder.SetMaxDynamicTableSizeLimit(conf.MaxEncoderHeaderTableSize)
327
+
328
+ fr := NewFramer(sc.bw, c)
329
+ if conf.CountError != nil {
330
+ fr.countError = conf.CountError
331
+ }
332
+ fr.ReadMetaHeaders = hpack.NewDecoder(conf.MaxDecoderHeaderTableSize, nil)
333
+ fr.MaxHeaderListSize = sc.maxHeaderListSize()
334
+ fr.SetMaxReadFrameSize(conf.MaxReadFrameSize)
335
+ sc.framer = fr
336
+
337
+ if tc, ok := c.(connectionStater); ok {
338
+ sc.tlsState = new(tls.ConnectionState)
339
+ *sc.tlsState = tc.ConnectionState()
340
+ // 9.2 Use of TLS Features
341
+ // An implementation of HTTP/2 over TLS MUST use TLS
342
+ // 1.2 or higher with the restrictions on feature set
343
+ // and cipher suite described in this section. Due to
344
+ // implementation limitations, it might not be
345
+ // possible to fail TLS negotiation. An endpoint MUST
346
+ // immediately terminate an HTTP/2 connection that
347
+ // does not meet the TLS requirements described in
348
+ // this section with a connection error (Section
349
+ // 5.4.1) of type INADEQUATE_SECURITY.
350
+ if sc.tlsState.Version < tls.VersionTLS12 {
351
+ sc.rejectConn(ErrCodeInadequateSecurity, "TLS version too low")
352
+ return
353
+ }
354
+
355
+ if sc.tlsState.ServerName == "" {
356
+ // Client must use SNI, but we don't enforce that anymore,
357
+ // since it was causing problems when connecting to bare IP
358
+ // addresses during development.
359
+ //
360
+ // TODO: optionally enforce? Or enforce at the time we receive
361
+ // a new request, and verify the ServerName matches the :authority?
362
+ // But that precludes proxy situations, perhaps.
363
+ //
364
+ // So for now, do nothing here again.
365
+ }
366
+
367
+ if !conf.PermitProhibitedCipherSuites && isBadCipher(sc.tlsState.CipherSuite) {
368
+ // "Endpoints MAY choose to generate a connection error
369
+ // (Section 5.4.1) of type INADEQUATE_SECURITY if one of
370
+ // the prohibited cipher suites are negotiated."
371
+ //
372
+ // We choose that. In my opinion, the spec is weak
373
+ // here. It also says both parties must support at least
374
+ // TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 so there's no
375
+ // excuses here. If we really must, we could allow an
376
+ // "AllowInsecureWeakCiphers" option on the server later.
377
+ // Let's see how it plays out first.
378
+ sc.rejectConn(ErrCodeInadequateSecurity, fmt.Sprintf("Prohibited TLS 1.2 Cipher Suite: %x", sc.tlsState.CipherSuite))
379
+ return
380
+ }
381
+ }
382
+
383
+ if opts.Settings != nil {
384
+ fr := &SettingsFrame{
385
+ FrameHeader: FrameHeader{valid: true},
386
+ p: opts.Settings,
387
+ }
388
+ if err := fr.ForeachSetting(sc.processSetting); err != nil {
389
+ sc.rejectConn(ErrCodeProtocol, "invalid settings")
390
+ return
391
+ }
392
+ opts.Settings = nil
393
+ }
394
+
395
+ if hook := testHookGetServerConn; hook != nil {
396
+ hook(sc)
397
+ }
398
+
399
+ if opts.UpgradeRequest != nil {
400
+ sc.upgradeRequest(opts.UpgradeRequest)
401
+ opts.UpgradeRequest = nil
402
+ }
403
+
404
+ sc.serve(conf)
405
+ }
406
+
407
+ func (sc *serverConn) rejectConn(err ErrCode, debug string) {
408
+ sc.vlogf("http2: server rejecting conn: %v, %s", err, debug)
409
+ // ignoring errors. hanging up anyway.
410
+ sc.framer.WriteGoAway(0, err, []byte(debug))
411
+ sc.bw.Flush()
412
+ sc.conn.Close()
413
+ }
414
+
415
+ type serverConn struct {
416
+ // Immutable:
417
+ srv *Server
418
+ hs *http.Server
419
+ conn net.Conn
420
+ bw *bufferedWriter // writing to conn
421
+ handler http.Handler
422
+ baseCtx context.Context
423
+ framer *Framer
424
+ doneServing chan struct{} // closed when serverConn.serve ends
425
+ readFrameCh chan readFrameResult // written by serverConn.readFrames
426
+ wantWriteFrameCh chan FrameWriteRequest // from handlers -> serve
427
+ wroteFrameCh chan frameWriteResult // from writeFrameAsync -> serve, tickles more frame writes
428
+ bodyReadCh chan bodyReadMsg // from handlers -> serve
429
+ serveMsgCh chan interface{} // misc messages & code to send to / run on the serve loop
430
+ flow outflow // conn-wide (not stream-specific) outbound flow control
431
+ inflow inflow // conn-wide inbound flow control
432
+ tlsState *tls.ConnectionState // shared by all handlers, like net/http
433
+ remoteAddrStr string
434
+ writeSched WriteScheduler
435
+ countErrorFunc func(errType string)
436
+
437
+ // Everything following is owned by the serve loop; use serveG.check():
438
+ serveG goroutineLock // used to verify funcs are on serve()
439
+ pushEnabled bool
440
+ sawClientPreface bool // preface has already been read, used in h2c upgrade
441
+ sawFirstSettings bool // got the initial SETTINGS frame after the preface
442
+ needToSendSettingsAck bool
443
+ unackedSettings int // how many SETTINGS have we sent without ACKs?
444
+ queuedControlFrames int // control frames in the writeSched queue
445
+ clientMaxStreams uint32 // SETTINGS_MAX_CONCURRENT_STREAMS from client (our PUSH_PROMISE limit)
446
+ advMaxStreams uint32 // our SETTINGS_MAX_CONCURRENT_STREAMS advertised the client
447
+ curClientStreams uint32 // number of open streams initiated by the client
448
+ curPushedStreams uint32 // number of open streams initiated by server push
449
+ curHandlers uint32 // number of running handler goroutines
450
+ maxClientStreamID uint32 // max ever seen from client (odd), or 0 if there have been no client requests
451
+ maxPushPromiseID uint32 // ID of the last push promise (even), or 0 if there have been no pushes
452
+ streams map[uint32]*stream
453
+ unstartedHandlers []unstartedHandler
454
+ initialStreamSendWindowSize int32
455
+ initialStreamRecvWindowSize int32
456
+ maxFrameSize int32
457
+ peerMaxHeaderListSize uint32 // zero means unknown (default)
458
+ canonHeader map[string]string // http2-lower-case -> Go-Canonical-Case
459
+ canonHeaderKeysSize int // canonHeader keys size in bytes
460
+ writingFrame bool // started writing a frame (on serve goroutine or separate)
461
+ writingFrameAsync bool // started a frame on its own goroutine but haven't heard back on wroteFrameCh
462
+ needsFrameFlush bool // last frame write wasn't a flush
463
+ inGoAway bool // we've started to or sent GOAWAY
464
+ inFrameScheduleLoop bool // whether we're in the scheduleFrameWrite loop
465
+ needToSendGoAway bool // we need to schedule a GOAWAY frame write
466
+ pingSent bool
467
+ sentPingData [8]byte
468
+ goAwayCode ErrCode
469
+ shutdownTimer *time.Timer // nil until used
470
+ idleTimer *time.Timer // nil if unused
471
+ readIdleTimeout time.Duration
472
+ pingTimeout time.Duration
473
+ readIdleTimer *time.Timer // nil if unused
474
+
475
+ // Owned by the writeFrameAsync goroutine:
476
+ headerWriteBuf bytes.Buffer
477
+ hpackEncoder *hpack.Encoder
478
+
479
+ // Used by startGracefulShutdown.
480
+ shutdownOnce sync.Once
481
+
482
+ // Used for RFC 9218 prioritization.
483
+ hasIntermediary bool // connection is done via an intermediary / proxy
484
+ priorityAware bool // the client has sent priority signal, meaning that it is aware of it.
485
+ }
486
+
487
+ func (sc *serverConn) writeSchedIgnoresRFC7540() bool {
488
+ switch sc.writeSched.(type) {
489
+ case *priorityWriteSchedulerRFC9218:
490
+ return true
491
+ case *randomWriteScheduler:
492
+ return true
493
+ case *roundRobinWriteScheduler:
494
+ return true
495
+ default:
496
+ return false
497
+ }
498
+ }
499
+
500
+ func (sc *serverConn) maxHeaderListSize() uint32 {
501
+ n := sc.hs.MaxHeaderBytes
502
+ if n <= 0 {
503
+ n = http.DefaultMaxHeaderBytes
504
+ }
505
+ return uint32(adjustHTTP1MaxHeaderSize(int64(n)))
506
+ }
507
+
508
+ func (sc *serverConn) curOpenStreams() uint32 {
509
+ sc.serveG.check()
510
+ return sc.curClientStreams + sc.curPushedStreams
511
+ }
512
+
513
+ // stream represents a stream. This is the minimal metadata needed by
514
+ // the serve goroutine. Most of the actual stream state is owned by
515
+ // the http.Handler's goroutine in the responseWriter. Because the
516
+ // responseWriter's responseWriterState is recycled at the end of a
517
+ // handler, this struct intentionally has no pointer to the
518
+ // *responseWriter{,State} itself, as the Handler ending nils out the
519
+ // responseWriter's state field.
520
+ type stream struct {
521
+ // immutable:
522
+ sc *serverConn
523
+ id uint32
524
+ body *pipe // non-nil if expecting DATA frames
525
+ cw closeWaiter // closed wait stream transitions to closed state
526
+ ctx context.Context
527
+ cancelCtx func()
528
+
529
+ // owned by serverConn's serve loop:
530
+ bodyBytes int64 // body bytes seen so far
531
+ declBodyBytes int64 // or -1 if undeclared
532
+ flow outflow // limits writing from Handler to client
533
+ inflow inflow // what the client is allowed to POST/etc to us
534
+ state streamState
535
+ resetQueued bool // RST_STREAM queued for write; set by sc.resetStream
536
+ gotTrailerHeader bool // HEADER frame for trailers was seen
537
+ wroteHeaders bool // whether we wrote headers (not status 100)
538
+ readDeadline *time.Timer // nil if unused
539
+ writeDeadline *time.Timer // nil if unused
540
+ closeErr error // set before cw is closed
541
+
542
+ trailer http.Header // accumulated trailers
543
+ reqTrailer http.Header // handler's Request.Trailer
544
+ }
545
+
546
+ func (sc *serverConn) Framer() *Framer { return sc.framer }
547
+ func (sc *serverConn) CloseConn() error { return sc.conn.Close() }
548
+ func (sc *serverConn) Flush() error { return sc.bw.Flush() }
549
+ func (sc *serverConn) HeaderEncoder() (*hpack.Encoder, *bytes.Buffer) {
550
+ return sc.hpackEncoder, &sc.headerWriteBuf
551
+ }
552
+
553
+ func (sc *serverConn) state(streamID uint32) (streamState, *stream) {
554
+ sc.serveG.check()
555
+ // http://tools.ietf.org/html/rfc7540#section-5.1
556
+ if st, ok := sc.streams[streamID]; ok {
557
+ return st.state, st
558
+ }
559
+ // "The first use of a new stream identifier implicitly closes all
560
+ // streams in the "idle" state that might have been initiated by
561
+ // that peer with a lower-valued stream identifier. For example, if
562
+ // a client sends a HEADERS frame on stream 7 without ever sending a
563
+ // frame on stream 5, then stream 5 transitions to the "closed"
564
+ // state when the first frame for stream 7 is sent or received."
565
+ if streamID%2 == 1 {
566
+ if streamID <= sc.maxClientStreamID {
567
+ return stateClosed, nil
568
+ }
569
+ } else {
570
+ if streamID <= sc.maxPushPromiseID {
571
+ return stateClosed, nil
572
+ }
573
+ }
574
+ return stateIdle, nil
575
+ }
576
+
577
+ // setConnState calls the net/http ConnState hook for this connection, if configured.
578
+ // Note that the net/http package does StateNew and StateClosed for us.
579
+ // There is currently no plan for StateHijacked or hijacking HTTP/2 connections.
580
+ func (sc *serverConn) setConnState(state http.ConnState) {
581
+ if sc.hs.ConnState != nil {
582
+ sc.hs.ConnState(sc.conn, state)
583
+ }
584
+ }
585
+
586
+ func (sc *serverConn) vlogf(format string, args ...interface{}) {
587
+ if VerboseLogs {
588
+ sc.logf(format, args...)
589
+ }
590
+ }
591
+
592
+ func (sc *serverConn) logf(format string, args ...interface{}) {
593
+ if lg := sc.hs.ErrorLog; lg != nil {
594
+ lg.Printf(format, args...)
595
+ } else {
596
+ log.Printf(format, args...)
597
+ }
598
+ }
599
+
600
+ // errno returns v's underlying uintptr, else 0.
601
+ //
602
+ // TODO: remove this helper function once http2 can use build
603
+ // tags. See comment in isClosedConnError.
604
+ func errno(v error) uintptr {
605
+ if rv := reflect.ValueOf(v); rv.Kind() == reflect.Uintptr {
606
+ return uintptr(rv.Uint())
607
+ }
608
+ return 0
609
+ }
610
+
611
+ // isClosedConnError reports whether err is an error from use of a closed
612
+ // network connection.
613
+ func isClosedConnError(err error) bool {
614
+ if err == nil {
615
+ return false
616
+ }
617
+
618
+ if errors.Is(err, net.ErrClosed) {
619
+ return true
620
+ }
621
+
622
+ // TODO(bradfitz): x/tools/cmd/bundle doesn't really support
623
+ // build tags, so I can't make an http2_windows.go file with
624
+ // Windows-specific stuff. Fix that and move this, once we
625
+ // have a way to bundle this into std's net/http somehow.
626
+ if runtime.GOOS == "windows" {
627
+ if oe, ok := err.(*net.OpError); ok && oe.Op == "read" {
628
+ if se, ok := oe.Err.(*os.SyscallError); ok && se.Syscall == "wsarecv" {
629
+ const WSAECONNABORTED = 10053
630
+ const WSAECONNRESET = 10054
631
+ if n := errno(se.Err); n == WSAECONNRESET || n == WSAECONNABORTED {
632
+ return true
633
+ }
634
+ }
635
+ }
636
+ }
637
+ return false
638
+ }
639
+
640
+ func (sc *serverConn) condlogf(err error, format string, args ...interface{}) {
641
+ if err == nil {
642
+ return
643
+ }
644
+ if err == io.EOF || err == io.ErrUnexpectedEOF || isClosedConnError(err) || err == errPrefaceTimeout {
645
+ // Boring, expected errors.
646
+ sc.vlogf(format, args...)
647
+ } else {
648
+ sc.logf(format, args...)
649
+ }
650
+ }
651
+
652
+ // maxCachedCanonicalHeadersKeysSize is an arbitrarily-chosen limit on the size
653
+ // of the entries in the canonHeader cache.
654
+ // This should be larger than the size of unique, uncommon header keys likely to
655
+ // be sent by the peer, while not so high as to permit unreasonable memory usage
656
+ // if the peer sends an unbounded number of unique header keys.
657
+ const maxCachedCanonicalHeadersKeysSize = 2048
658
+
659
+ func (sc *serverConn) canonicalHeader(v string) string {
660
+ sc.serveG.check()
661
+ cv, ok := httpcommon.CachedCanonicalHeader(v)
662
+ if ok {
663
+ return cv
664
+ }
665
+ cv, ok = sc.canonHeader[v]
666
+ if ok {
667
+ return cv
668
+ }
669
+ if sc.canonHeader == nil {
670
+ sc.canonHeader = make(map[string]string)
671
+ }
672
+ cv = http.CanonicalHeaderKey(v)
673
+ size := 100 + len(v)*2 // 100 bytes of map overhead + key + value
674
+ if sc.canonHeaderKeysSize+size <= maxCachedCanonicalHeadersKeysSize {
675
+ sc.canonHeader[v] = cv
676
+ sc.canonHeaderKeysSize += size
677
+ }
678
+ return cv
679
+ }
680
+
681
+ type readFrameResult struct {
682
+ f Frame // valid until readMore is called
683
+ err error
684
+
685
+ // readMore should be called once the consumer no longer needs or
686
+ // retains f. After readMore, f is invalid and more frames can be
687
+ // read.
688
+ readMore func()
689
+ }
690
+
691
+ // readFrames is the loop that reads incoming frames.
692
+ // It takes care to only read one frame at a time, blocking until the
693
+ // consumer is done with the frame.
694
+ // It's run on its own goroutine.
695
+ func (sc *serverConn) readFrames() {
696
+ gate := make(chan struct{})
697
+ gateDone := func() { gate <- struct{}{} }
698
+ for {
699
+ f, err := sc.framer.ReadFrame()
700
+ select {
701
+ case sc.readFrameCh <- readFrameResult{f, err, gateDone}:
702
+ case <-sc.doneServing:
703
+ return
704
+ }
705
+ select {
706
+ case <-gate:
707
+ case <-sc.doneServing:
708
+ return
709
+ }
710
+ if terminalReadFrameError(err) {
711
+ return
712
+ }
713
+ }
714
+ }
715
+
716
+ // frameWriteResult is the message passed from writeFrameAsync to the serve goroutine.
717
+ type frameWriteResult struct {
718
+ _ incomparable
719
+ wr FrameWriteRequest // what was written (or attempted)
720
+ err error // result of the writeFrame call
721
+ }
722
+
723
+ // writeFrameAsync runs in its own goroutine and writes a single frame
724
+ // and then reports when it's done.
725
+ // At most one goroutine can be running writeFrameAsync at a time per
726
+ // serverConn.
727
+ func (sc *serverConn) writeFrameAsync(wr FrameWriteRequest, wd *writeData) {
728
+ var err error
729
+ if wd == nil {
730
+ err = wr.write.writeFrame(sc)
731
+ } else {
732
+ err = sc.framer.endWrite()
733
+ }
734
+ sc.wroteFrameCh <- frameWriteResult{wr: wr, err: err}
735
+ }
736
+
737
+ func (sc *serverConn) closeAllStreamsOnConnClose() {
738
+ sc.serveG.check()
739
+ for _, st := range sc.streams {
740
+ sc.closeStream(st, errClientDisconnected)
741
+ }
742
+ }
743
+
744
+ func (sc *serverConn) stopShutdownTimer() {
745
+ sc.serveG.check()
746
+ if t := sc.shutdownTimer; t != nil {
747
+ t.Stop()
748
+ }
749
+ }
750
+
751
+ func (sc *serverConn) notePanic() {
752
+ // Note: this is for serverConn.serve panicking, not http.Handler code.
753
+ if testHookOnPanicMu != nil {
754
+ testHookOnPanicMu.Lock()
755
+ defer testHookOnPanicMu.Unlock()
756
+ }
757
+ if testHookOnPanic != nil {
758
+ if e := recover(); e != nil {
759
+ if testHookOnPanic(sc, e) {
760
+ panic(e)
761
+ }
762
+ }
763
+ }
764
+ }
765
+
766
+ func (sc *serverConn) serve(conf http2Config) {
767
+ sc.serveG.check()
768
+ defer sc.notePanic()
769
+ defer sc.conn.Close()
770
+ defer sc.closeAllStreamsOnConnClose()
771
+ defer sc.stopShutdownTimer()
772
+ defer close(sc.doneServing) // unblocks handlers trying to send
773
+
774
+ if VerboseLogs {
775
+ sc.vlogf("http2: server connection from %v on %p", sc.conn.RemoteAddr(), sc.hs)
776
+ }
777
+
778
+ settings := writeSettings{
779
+ {SettingMaxFrameSize, conf.MaxReadFrameSize},
780
+ {SettingMaxConcurrentStreams, sc.advMaxStreams},
781
+ {SettingMaxHeaderListSize, sc.maxHeaderListSize()},
782
+ {SettingHeaderTableSize, conf.MaxDecoderHeaderTableSize},
783
+ {SettingInitialWindowSize, uint32(sc.initialStreamRecvWindowSize)},
784
+ }
785
+ if !disableExtendedConnectProtocol {
786
+ settings = append(settings, Setting{SettingEnableConnectProtocol, 1})
787
+ }
788
+ if sc.writeSchedIgnoresRFC7540() {
789
+ settings = append(settings, Setting{SettingNoRFC7540Priorities, 1})
790
+ }
791
+ sc.writeFrame(FrameWriteRequest{
792
+ write: settings,
793
+ })
794
+ sc.unackedSettings++
795
+
796
+ // Each connection starts with initialWindowSize inflow tokens.
797
+ // If a higher value is configured, we add more tokens.
798
+ if diff := conf.MaxUploadBufferPerConnection - initialWindowSize; diff > 0 {
799
+ sc.sendWindowUpdate(nil, int(diff))
800
+ }
801
+
802
+ if err := sc.readPreface(); err != nil {
803
+ sc.condlogf(err, "http2: server: error reading preface from client %v: %v", sc.conn.RemoteAddr(), err)
804
+ return
805
+ }
806
+ // Now that we've got the preface, get us out of the
807
+ // "StateNew" state. We can't go directly to idle, though.
808
+ // Active means we read some data and anticipate a request. We'll
809
+ // do another Active when we get a HEADERS frame.
810
+ sc.setConnState(http.StateActive)
811
+ sc.setConnState(http.StateIdle)
812
+
813
+ if sc.srv.IdleTimeout > 0 {
814
+ sc.idleTimer = time.AfterFunc(sc.srv.IdleTimeout, sc.onIdleTimer)
815
+ defer sc.idleTimer.Stop()
816
+ }
817
+
818
+ if conf.SendPingTimeout > 0 {
819
+ sc.readIdleTimeout = conf.SendPingTimeout
820
+ sc.readIdleTimer = time.AfterFunc(conf.SendPingTimeout, sc.onReadIdleTimer)
821
+ defer sc.readIdleTimer.Stop()
822
+ }
823
+
824
+ go sc.readFrames() // closed by defer sc.conn.Close above
825
+
826
+ settingsTimer := time.AfterFunc(firstSettingsTimeout, sc.onSettingsTimer)
827
+ defer settingsTimer.Stop()
828
+
829
+ lastFrameTime := time.Now()
830
+ loopNum := 0
831
+ for {
832
+ loopNum++
833
+ select {
834
+ case wr := <-sc.wantWriteFrameCh:
835
+ if se, ok := wr.write.(StreamError); ok {
836
+ sc.resetStream(se)
837
+ break
838
+ }
839
+ sc.writeFrame(wr)
840
+ case res := <-sc.wroteFrameCh:
841
+ sc.wroteFrame(res)
842
+ case res := <-sc.readFrameCh:
843
+ lastFrameTime = time.Now()
844
+ // Process any written frames before reading new frames from the client since a
845
+ // written frame could have triggered a new stream to be started.
846
+ if sc.writingFrameAsync {
847
+ select {
848
+ case wroteRes := <-sc.wroteFrameCh:
849
+ sc.wroteFrame(wroteRes)
850
+ default:
851
+ }
852
+ }
853
+ if !sc.processFrameFromReader(res) {
854
+ return
855
+ }
856
+ res.readMore()
857
+ if settingsTimer != nil {
858
+ settingsTimer.Stop()
859
+ settingsTimer = nil
860
+ }
861
+ case m := <-sc.bodyReadCh:
862
+ sc.noteBodyRead(m.st, m.n)
863
+ case msg := <-sc.serveMsgCh:
864
+ switch v := msg.(type) {
865
+ case func(int):
866
+ v(loopNum) // for testing
867
+ case *serverMessage:
868
+ switch v {
869
+ case settingsTimerMsg:
870
+ sc.logf("timeout waiting for SETTINGS frames from %v", sc.conn.RemoteAddr())
871
+ return
872
+ case idleTimerMsg:
873
+ sc.vlogf("connection is idle")
874
+ sc.goAway(ErrCodeNo)
875
+ case readIdleTimerMsg:
876
+ sc.handlePingTimer(lastFrameTime)
877
+ case shutdownTimerMsg:
878
+ sc.vlogf("GOAWAY close timer fired; closing conn from %v", sc.conn.RemoteAddr())
879
+ return
880
+ case gracefulShutdownMsg:
881
+ sc.startGracefulShutdownInternal()
882
+ case handlerDoneMsg:
883
+ sc.handlerDone()
884
+ default:
885
+ panic("unknown timer")
886
+ }
887
+ case *startPushRequest:
888
+ sc.startPush(v)
889
+ case func(*serverConn):
890
+ v(sc)
891
+ default:
892
+ panic(fmt.Sprintf("unexpected type %T", v))
893
+ }
894
+ }
895
+
896
+ // If the peer is causing us to generate a lot of control frames,
897
+ // but not reading them from us, assume they are trying to make us
898
+ // run out of memory.
899
+ if sc.queuedControlFrames > maxQueuedControlFrames {
900
+ sc.vlogf("http2: too many control frames in send queue, closing connection")
901
+ return
902
+ }
903
+
904
+ // Start the shutdown timer after sending a GOAWAY. When sending GOAWAY
905
+ // with no error code (graceful shutdown), don't start the timer until
906
+ // all open streams have been completed.
907
+ sentGoAway := sc.inGoAway && !sc.needToSendGoAway && !sc.writingFrame
908
+ gracefulShutdownComplete := sc.goAwayCode == ErrCodeNo && sc.curOpenStreams() == 0
909
+ if sentGoAway && sc.shutdownTimer == nil && (sc.goAwayCode != ErrCodeNo || gracefulShutdownComplete) {
910
+ sc.shutDownIn(goAwayTimeout)
911
+ }
912
+ }
913
+ }
914
+
915
+ func (sc *serverConn) handlePingTimer(lastFrameReadTime time.Time) {
916
+ if sc.pingSent {
917
+ sc.logf("timeout waiting for PING response")
918
+ if f := sc.countErrorFunc; f != nil {
919
+ f("conn_close_lost_ping")
920
+ }
921
+ sc.conn.Close()
922
+ return
923
+ }
924
+
925
+ pingAt := lastFrameReadTime.Add(sc.readIdleTimeout)
926
+ now := time.Now()
927
+ if pingAt.After(now) {
928
+ // We received frames since arming the ping timer.
929
+ // Reset it for the next possible timeout.
930
+ sc.readIdleTimer.Reset(pingAt.Sub(now))
931
+ return
932
+ }
933
+
934
+ sc.pingSent = true
935
+ // Ignore crypto/rand.Read errors: It generally can't fail, and worse case if it does
936
+ // is we send a PING frame containing 0s.
937
+ _, _ = rand.Read(sc.sentPingData[:])
938
+ sc.writeFrame(FrameWriteRequest{
939
+ write: &writePing{data: sc.sentPingData},
940
+ })
941
+ sc.readIdleTimer.Reset(sc.pingTimeout)
942
+ }
943
+
944
+ type serverMessage int
945
+
946
+ // Message values sent to serveMsgCh.
947
+ var (
948
+ settingsTimerMsg = new(serverMessage)
949
+ idleTimerMsg = new(serverMessage)
950
+ readIdleTimerMsg = new(serverMessage)
951
+ shutdownTimerMsg = new(serverMessage)
952
+ gracefulShutdownMsg = new(serverMessage)
953
+ handlerDoneMsg = new(serverMessage)
954
+ )
955
+
956
+ func (sc *serverConn) onSettingsTimer() { sc.sendServeMsg(settingsTimerMsg) }
957
+ func (sc *serverConn) onIdleTimer() { sc.sendServeMsg(idleTimerMsg) }
958
+ func (sc *serverConn) onReadIdleTimer() { sc.sendServeMsg(readIdleTimerMsg) }
959
+ func (sc *serverConn) onShutdownTimer() { sc.sendServeMsg(shutdownTimerMsg) }
960
+
961
+ func (sc *serverConn) sendServeMsg(msg interface{}) {
962
+ sc.serveG.checkNotOn() // NOT
963
+ select {
964
+ case sc.serveMsgCh <- msg:
965
+ case <-sc.doneServing:
966
+ }
967
+ }
968
+
969
+ var errPrefaceTimeout = errors.New("timeout waiting for client preface")
970
+
971
+ // readPreface reads the ClientPreface greeting from the peer or
972
+ // returns errPrefaceTimeout on timeout, or an error if the greeting
973
+ // is invalid.
974
+ func (sc *serverConn) readPreface() error {
975
+ if sc.sawClientPreface {
976
+ return nil
977
+ }
978
+ errc := make(chan error, 1)
979
+ go func() {
980
+ // Read the client preface
981
+ buf := make([]byte, len(ClientPreface))
982
+ if _, err := io.ReadFull(sc.conn, buf); err != nil {
983
+ errc <- err
984
+ } else if !bytes.Equal(buf, clientPreface) {
985
+ errc <- fmt.Errorf("bogus greeting %q", buf)
986
+ } else {
987
+ errc <- nil
988
+ }
989
+ }()
990
+ timer := time.NewTimer(prefaceTimeout) // TODO: configurable on *Server?
991
+ defer timer.Stop()
992
+ select {
993
+ case <-timer.C:
994
+ return errPrefaceTimeout
995
+ case err := <-errc:
996
+ if err == nil {
997
+ if VerboseLogs {
998
+ sc.vlogf("http2: server: client %v said hello", sc.conn.RemoteAddr())
999
+ }
1000
+ }
1001
+ return err
1002
+ }
1003
+ }
1004
+
1005
+ var writeDataPool = sync.Pool{
1006
+ New: func() interface{} { return new(writeData) },
1007
+ }
1008
+
1009
+ // writeDataFromHandler writes DATA response frames from a handler on
1010
+ // the given stream.
1011
+ func (sc *serverConn) writeDataFromHandler(stream *stream, data []byte, endStream bool) error {
1012
+ ch := sc.srv.state.getErrChan()
1013
+ writeArg := writeDataPool.Get().(*writeData)
1014
+ *writeArg = writeData{stream.id, data, endStream}
1015
+ err := sc.writeFrameFromHandler(FrameWriteRequest{
1016
+ write: writeArg,
1017
+ stream: stream,
1018
+ done: ch,
1019
+ })
1020
+ if err != nil {
1021
+ return err
1022
+ }
1023
+ var frameWriteDone bool // the frame write is done (successfully or not)
1024
+ select {
1025
+ case err = <-ch:
1026
+ frameWriteDone = true
1027
+ case <-sc.doneServing:
1028
+ return errClientDisconnected
1029
+ case <-stream.cw:
1030
+ // If both ch and stream.cw were ready (as might
1031
+ // happen on the final Write after an http.Handler
1032
+ // ends), prefer the write result. Otherwise this
1033
+ // might just be us successfully closing the stream.
1034
+ // The writeFrameAsync and serve goroutines guarantee
1035
+ // that the ch send will happen before the stream.cw
1036
+ // close.
1037
+ select {
1038
+ case err = <-ch:
1039
+ frameWriteDone = true
1040
+ default:
1041
+ return errStreamClosed
1042
+ }
1043
+ }
1044
+ sc.srv.state.putErrChan(ch)
1045
+ if frameWriteDone {
1046
+ writeDataPool.Put(writeArg)
1047
+ }
1048
+ return err
1049
+ }
1050
+
1051
+ // writeFrameFromHandler sends wr to sc.wantWriteFrameCh, but aborts
1052
+ // if the connection has gone away.
1053
+ //
1054
+ // This must not be run from the serve goroutine itself, else it might
1055
+ // deadlock writing to sc.wantWriteFrameCh (which is only mildly
1056
+ // buffered and is read by serve itself). If you're on the serve
1057
+ // goroutine, call writeFrame instead.
1058
+ func (sc *serverConn) writeFrameFromHandler(wr FrameWriteRequest) error {
1059
+ sc.serveG.checkNotOn() // NOT
1060
+ select {
1061
+ case sc.wantWriteFrameCh <- wr:
1062
+ return nil
1063
+ case <-sc.doneServing:
1064
+ // Serve loop is gone.
1065
+ // Client has closed their connection to the server.
1066
+ return errClientDisconnected
1067
+ }
1068
+ }
1069
+
1070
+ // writeFrame schedules a frame to write and sends it if there's nothing
1071
+ // already being written.
1072
+ //
1073
+ // There is no pushback here (the serve goroutine never blocks). It's
1074
+ // the http.Handlers that block, waiting for their previous frames to
1075
+ // make it onto the wire
1076
+ //
1077
+ // If you're not on the serve goroutine, use writeFrameFromHandler instead.
1078
+ func (sc *serverConn) writeFrame(wr FrameWriteRequest) {
1079
+ sc.serveG.check()
1080
+
1081
+ // If true, wr will not be written and wr.done will not be signaled.
1082
+ var ignoreWrite bool
1083
+
1084
+ // We are not allowed to write frames on closed streams. RFC 7540 Section
1085
+ // 5.1.1 says: "An endpoint MUST NOT send frames other than PRIORITY on
1086
+ // a closed stream." Our server never sends PRIORITY, so that exception
1087
+ // does not apply.
1088
+ //
1089
+ // The serverConn might close an open stream while the stream's handler
1090
+ // is still running. For example, the server might close a stream when it
1091
+ // receives bad data from the client. If this happens, the handler might
1092
+ // attempt to write a frame after the stream has been closed (since the
1093
+ // handler hasn't yet been notified of the close). In this case, we simply
1094
+ // ignore the frame. The handler will notice that the stream is closed when
1095
+ // it waits for the frame to be written.
1096
+ //
1097
+ // As an exception to this rule, we allow sending RST_STREAM after close.
1098
+ // This allows us to immediately reject new streams without tracking any
1099
+ // state for those streams (except for the queued RST_STREAM frame). This
1100
+ // may result in duplicate RST_STREAMs in some cases, but the client should
1101
+ // ignore those.
1102
+ if wr.StreamID() != 0 {
1103
+ _, isReset := wr.write.(StreamError)
1104
+ if state, _ := sc.state(wr.StreamID()); state == stateClosed && !isReset {
1105
+ ignoreWrite = true
1106
+ }
1107
+ }
1108
+
1109
+ // Don't send a 100-continue response if we've already sent headers.
1110
+ // See golang.org/issue/14030.
1111
+ switch wr.write.(type) {
1112
+ case *writeResHeaders:
1113
+ wr.stream.wroteHeaders = true
1114
+ case write100ContinueHeadersFrame:
1115
+ if wr.stream.wroteHeaders {
1116
+ // We do not need to notify wr.done because this frame is
1117
+ // never written with wr.done != nil.
1118
+ if wr.done != nil {
1119
+ panic("wr.done != nil for write100ContinueHeadersFrame")
1120
+ }
1121
+ ignoreWrite = true
1122
+ }
1123
+ }
1124
+
1125
+ if !ignoreWrite {
1126
+ if wr.isControl() {
1127
+ sc.queuedControlFrames++
1128
+ // For extra safety, detect wraparounds, which should not happen,
1129
+ // and pull the plug.
1130
+ if sc.queuedControlFrames < 0 {
1131
+ sc.conn.Close()
1132
+ }
1133
+ }
1134
+ sc.writeSched.Push(wr)
1135
+ }
1136
+ sc.scheduleFrameWrite()
1137
+ }
1138
+
1139
+ // startFrameWrite starts a goroutine to write wr (in a separate
1140
+ // goroutine since that might block on the network), and updates the
1141
+ // serve goroutine's state about the world, updated from info in wr.
1142
+ func (sc *serverConn) startFrameWrite(wr FrameWriteRequest) {
1143
+ sc.serveG.check()
1144
+ if sc.writingFrame {
1145
+ panic("internal error: can only be writing one frame at a time")
1146
+ }
1147
+
1148
+ st := wr.stream
1149
+ if st != nil {
1150
+ switch st.state {
1151
+ case stateHalfClosedLocal:
1152
+ switch wr.write.(type) {
1153
+ case StreamError, handlerPanicRST, writeWindowUpdate:
1154
+ // RFC 7540 Section 5.1 allows sending RST_STREAM, PRIORITY, and WINDOW_UPDATE
1155
+ // in this state. (We never send PRIORITY from the server, so that is not checked.)
1156
+ default:
1157
+ panic(fmt.Sprintf("internal error: attempt to send frame on a half-closed-local stream: %v", wr))
1158
+ }
1159
+ case stateClosed:
1160
+ panic(fmt.Sprintf("internal error: attempt to send frame on a closed stream: %v", wr))
1161
+ }
1162
+ }
1163
+ if wpp, ok := wr.write.(*writePushPromise); ok {
1164
+ var err error
1165
+ wpp.promisedID, err = wpp.allocatePromisedID()
1166
+ if err != nil {
1167
+ sc.writingFrameAsync = false
1168
+ wr.replyToWriter(err)
1169
+ return
1170
+ }
1171
+ }
1172
+
1173
+ sc.writingFrame = true
1174
+ sc.needsFrameFlush = true
1175
+ if wr.write.staysWithinBuffer(sc.bw.Available()) {
1176
+ sc.writingFrameAsync = false
1177
+ err := wr.write.writeFrame(sc)
1178
+ sc.wroteFrame(frameWriteResult{wr: wr, err: err})
1179
+ } else if wd, ok := wr.write.(*writeData); ok {
1180
+ // Encode the frame in the serve goroutine, to ensure we don't have
1181
+ // any lingering asynchronous references to data passed to Write.
1182
+ // See https://go.dev/issue/58446.
1183
+ sc.framer.startWriteDataPadded(wd.streamID, wd.endStream, wd.p, nil)
1184
+ sc.writingFrameAsync = true
1185
+ go sc.writeFrameAsync(wr, wd)
1186
+ } else {
1187
+ sc.writingFrameAsync = true
1188
+ go sc.writeFrameAsync(wr, nil)
1189
+ }
1190
+ }
1191
+
1192
+ // errHandlerPanicked is the error given to any callers blocked in a read from
1193
+ // Request.Body when the main goroutine panics. Since most handlers read in the
1194
+ // main ServeHTTP goroutine, this will show up rarely.
1195
+ var errHandlerPanicked = errors.New("http2: handler panicked")
1196
+
1197
+ // wroteFrame is called on the serve goroutine with the result of
1198
+ // whatever happened on writeFrameAsync.
1199
+ func (sc *serverConn) wroteFrame(res frameWriteResult) {
1200
+ sc.serveG.check()
1201
+ if !sc.writingFrame {
1202
+ panic("internal error: expected to be already writing a frame")
1203
+ }
1204
+ sc.writingFrame = false
1205
+ sc.writingFrameAsync = false
1206
+
1207
+ if res.err != nil {
1208
+ sc.conn.Close()
1209
+ }
1210
+
1211
+ wr := res.wr
1212
+
1213
+ if writeEndsStream(wr.write) {
1214
+ st := wr.stream
1215
+ if st == nil {
1216
+ panic("internal error: expecting non-nil stream")
1217
+ }
1218
+ switch st.state {
1219
+ case stateOpen:
1220
+ // Here we would go to stateHalfClosedLocal in
1221
+ // theory, but since our handler is done and
1222
+ // the net/http package provides no mechanism
1223
+ // for closing a ResponseWriter while still
1224
+ // reading data (see possible TODO at top of
1225
+ // this file), we go into closed state here
1226
+ // anyway, after telling the peer we're
1227
+ // hanging up on them. We'll transition to
1228
+ // stateClosed after the RST_STREAM frame is
1229
+ // written.
1230
+ st.state = stateHalfClosedLocal
1231
+ // Section 8.1: a server MAY request that the client abort
1232
+ // transmission of a request without error by sending a
1233
+ // RST_STREAM with an error code of NO_ERROR after sending
1234
+ // a complete response.
1235
+ sc.resetStream(streamError(st.id, ErrCodeNo))
1236
+ case stateHalfClosedRemote:
1237
+ sc.closeStream(st, errHandlerComplete)
1238
+ }
1239
+ } else {
1240
+ switch v := wr.write.(type) {
1241
+ case StreamError:
1242
+ // st may be unknown if the RST_STREAM was generated to reject bad input.
1243
+ if st, ok := sc.streams[v.StreamID]; ok {
1244
+ sc.closeStream(st, v)
1245
+ }
1246
+ case handlerPanicRST:
1247
+ sc.closeStream(wr.stream, errHandlerPanicked)
1248
+ }
1249
+ }
1250
+
1251
+ // Reply (if requested) to unblock the ServeHTTP goroutine.
1252
+ wr.replyToWriter(res.err)
1253
+
1254
+ sc.scheduleFrameWrite()
1255
+ }
1256
+
1257
+ // scheduleFrameWrite tickles the frame writing scheduler.
1258
+ //
1259
+ // If a frame is already being written, nothing happens. This will be called again
1260
+ // when the frame is done being written.
1261
+ //
1262
+ // If a frame isn't being written and we need to send one, the best frame
1263
+ // to send is selected by writeSched.
1264
+ //
1265
+ // If a frame isn't being written and there's nothing else to send, we
1266
+ // flush the write buffer.
1267
+ func (sc *serverConn) scheduleFrameWrite() {
1268
+ sc.serveG.check()
1269
+ if sc.writingFrame || sc.inFrameScheduleLoop {
1270
+ return
1271
+ }
1272
+ sc.inFrameScheduleLoop = true
1273
+ for !sc.writingFrameAsync {
1274
+ if sc.needToSendGoAway {
1275
+ sc.needToSendGoAway = false
1276
+ sc.startFrameWrite(FrameWriteRequest{
1277
+ write: &writeGoAway{
1278
+ maxStreamID: sc.maxClientStreamID,
1279
+ code: sc.goAwayCode,
1280
+ },
1281
+ })
1282
+ continue
1283
+ }
1284
+ if sc.needToSendSettingsAck {
1285
+ sc.needToSendSettingsAck = false
1286
+ sc.startFrameWrite(FrameWriteRequest{write: writeSettingsAck{}})
1287
+ continue
1288
+ }
1289
+ if !sc.inGoAway || sc.goAwayCode == ErrCodeNo {
1290
+ if wr, ok := sc.writeSched.Pop(); ok {
1291
+ if wr.isControl() {
1292
+ sc.queuedControlFrames--
1293
+ }
1294
+ sc.startFrameWrite(wr)
1295
+ continue
1296
+ }
1297
+ }
1298
+ if sc.needsFrameFlush {
1299
+ sc.startFrameWrite(FrameWriteRequest{write: flushFrameWriter{}})
1300
+ sc.needsFrameFlush = false // after startFrameWrite, since it sets this true
1301
+ continue
1302
+ }
1303
+ break
1304
+ }
1305
+ sc.inFrameScheduleLoop = false
1306
+ }
1307
+
1308
+ // startGracefulShutdown gracefully shuts down a connection. This
1309
+ // sends GOAWAY with ErrCodeNo to tell the client we're gracefully
1310
+ // shutting down. The connection isn't closed until all current
1311
+ // streams are done.
1312
+ //
1313
+ // startGracefulShutdown returns immediately; it does not wait until
1314
+ // the connection has shut down.
1315
+ func (sc *serverConn) startGracefulShutdown() {
1316
+ sc.serveG.checkNotOn() // NOT
1317
+ sc.shutdownOnce.Do(func() { sc.sendServeMsg(gracefulShutdownMsg) })
1318
+ }
1319
+
1320
+ // After sending GOAWAY with an error code (non-graceful shutdown), the
1321
+ // connection will close after goAwayTimeout.
1322
+ //
1323
+ // If we close the connection immediately after sending GOAWAY, there may
1324
+ // be unsent data in our kernel receive buffer, which will cause the kernel
1325
+ // to send a TCP RST on close() instead of a FIN. This RST will abort the
1326
+ // connection immediately, whether or not the client had received the GOAWAY.
1327
+ //
1328
+ // Ideally we should delay for at least 1 RTT + epsilon so the client has
1329
+ // a chance to read the GOAWAY and stop sending messages. Measuring RTT
1330
+ // is hard, so we approximate with 1 second. See golang.org/issue/18701.
1331
+ //
1332
+ // This is a var so it can be shorter in tests, where all requests uses the
1333
+ // loopback interface making the expected RTT very small.
1334
+ //
1335
+ // TODO: configurable?
1336
+ var goAwayTimeout = 1 * time.Second
1337
+
1338
+ func (sc *serverConn) startGracefulShutdownInternal() {
1339
+ sc.goAway(ErrCodeNo)
1340
+ }
1341
+
1342
+ func (sc *serverConn) goAway(code ErrCode) {
1343
+ sc.serveG.check()
1344
+ if sc.inGoAway {
1345
+ if sc.goAwayCode == ErrCodeNo {
1346
+ sc.goAwayCode = code
1347
+ }
1348
+ return
1349
+ }
1350
+ sc.inGoAway = true
1351
+ sc.needToSendGoAway = true
1352
+ sc.goAwayCode = code
1353
+ sc.scheduleFrameWrite()
1354
+ }
1355
+
1356
+ func (sc *serverConn) shutDownIn(d time.Duration) {
1357
+ sc.serveG.check()
1358
+ sc.shutdownTimer = time.AfterFunc(d, sc.onShutdownTimer)
1359
+ }
1360
+
1361
+ func (sc *serverConn) resetStream(se StreamError) {
1362
+ sc.serveG.check()
1363
+ sc.writeFrame(FrameWriteRequest{write: se})
1364
+ if st, ok := sc.streams[se.StreamID]; ok {
1365
+ st.resetQueued = true
1366
+ }
1367
+ }
1368
+
1369
+ // processFrameFromReader processes the serve loop's read from readFrameCh from the
1370
+ // frame-reading goroutine.
1371
+ // processFrameFromReader returns whether the connection should be kept open.
1372
+ func (sc *serverConn) processFrameFromReader(res readFrameResult) bool {
1373
+ sc.serveG.check()
1374
+ err := res.err
1375
+ if err != nil {
1376
+ if err == ErrFrameTooLarge {
1377
+ sc.goAway(ErrCodeFrameSize)
1378
+ return true // goAway will close the loop
1379
+ }
1380
+ clientGone := err == io.EOF || err == io.ErrUnexpectedEOF || isClosedConnError(err)
1381
+ if clientGone {
1382
+ // TODO: could we also get into this state if
1383
+ // the peer does a half close
1384
+ // (e.g. CloseWrite) because they're done
1385
+ // sending frames but they're still wanting
1386
+ // our open replies? Investigate.
1387
+ // TODO: add CloseWrite to crypto/tls.Conn first
1388
+ // so we have a way to test this? I suppose
1389
+ // just for testing we could have a non-TLS mode.
1390
+ return false
1391
+ }
1392
+ } else {
1393
+ f := res.f
1394
+ if VerboseLogs {
1395
+ sc.vlogf("http2: server read frame %v", summarizeFrame(f))
1396
+ }
1397
+ err = sc.processFrame(f)
1398
+ if err == nil {
1399
+ return true
1400
+ }
1401
+ }
1402
+
1403
+ switch ev := err.(type) {
1404
+ case StreamError:
1405
+ sc.resetStream(ev)
1406
+ return true
1407
+ case goAwayFlowError:
1408
+ sc.goAway(ErrCodeFlowControl)
1409
+ return true
1410
+ case ConnectionError:
1411
+ if res.f != nil {
1412
+ if id := res.f.Header().StreamID; id > sc.maxClientStreamID {
1413
+ sc.maxClientStreamID = id
1414
+ }
1415
+ }
1416
+ sc.logf("http2: server connection error from %v: %v", sc.conn.RemoteAddr(), ev)
1417
+ sc.goAway(ErrCode(ev))
1418
+ return true // goAway will handle shutdown
1419
+ default:
1420
+ if res.err != nil {
1421
+ sc.vlogf("http2: server closing client connection; error reading frame from client %s: %v", sc.conn.RemoteAddr(), err)
1422
+ } else {
1423
+ sc.logf("http2: server closing client connection: %v", err)
1424
+ }
1425
+ return false
1426
+ }
1427
+ }
1428
+
1429
+ func (sc *serverConn) processFrame(f Frame) error {
1430
+ sc.serveG.check()
1431
+
1432
+ // First frame received must be SETTINGS.
1433
+ if !sc.sawFirstSettings {
1434
+ if _, ok := f.(*SettingsFrame); !ok {
1435
+ return sc.countError("first_settings", ConnectionError(ErrCodeProtocol))
1436
+ }
1437
+ sc.sawFirstSettings = true
1438
+ }
1439
+
1440
+ // Discard frames for streams initiated after the identified last
1441
+ // stream sent in a GOAWAY, or all frames after sending an error.
1442
+ // We still need to return connection-level flow control for DATA frames.
1443
+ // RFC 9113 Section 6.8.
1444
+ if sc.inGoAway && (sc.goAwayCode != ErrCodeNo || f.Header().StreamID > sc.maxClientStreamID) {
1445
+
1446
+ if f, ok := f.(*DataFrame); ok {
1447
+ if !sc.inflow.take(f.Length) {
1448
+ return sc.countError("data_flow", streamError(f.Header().StreamID, ErrCodeFlowControl))
1449
+ }
1450
+ sc.sendWindowUpdate(nil, int(f.Length)) // conn-level
1451
+ }
1452
+ return nil
1453
+ }
1454
+
1455
+ switch f := f.(type) {
1456
+ case *SettingsFrame:
1457
+ return sc.processSettings(f)
1458
+ case *MetaHeadersFrame:
1459
+ return sc.processHeaders(f)
1460
+ case *WindowUpdateFrame:
1461
+ return sc.processWindowUpdate(f)
1462
+ case *PingFrame:
1463
+ return sc.processPing(f)
1464
+ case *DataFrame:
1465
+ return sc.processData(f)
1466
+ case *RSTStreamFrame:
1467
+ return sc.processResetStream(f)
1468
+ case *PriorityFrame:
1469
+ return sc.processPriority(f)
1470
+ case *GoAwayFrame:
1471
+ return sc.processGoAway(f)
1472
+ case *PushPromiseFrame:
1473
+ // A client cannot push. Thus, servers MUST treat the receipt of a PUSH_PROMISE
1474
+ // frame as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.
1475
+ return sc.countError("push_promise", ConnectionError(ErrCodeProtocol))
1476
+ case *PriorityUpdateFrame:
1477
+ return sc.processPriorityUpdate(f)
1478
+ default:
1479
+ sc.vlogf("http2: server ignoring frame: %v", f.Header())
1480
+ return nil
1481
+ }
1482
+ }
1483
+
1484
+ func (sc *serverConn) processPing(f *PingFrame) error {
1485
+ sc.serveG.check()
1486
+ if f.IsAck() {
1487
+ if sc.pingSent && sc.sentPingData == f.Data {
1488
+ // This is a response to a PING we sent.
1489
+ sc.pingSent = false
1490
+ sc.readIdleTimer.Reset(sc.readIdleTimeout)
1491
+ }
1492
+ // 6.7 PING: " An endpoint MUST NOT respond to PING frames
1493
+ // containing this flag."
1494
+ return nil
1495
+ }
1496
+ if f.StreamID != 0 {
1497
+ // "PING frames are not associated with any individual
1498
+ // stream. If a PING frame is received with a stream
1499
+ // identifier field value other than 0x0, the recipient MUST
1500
+ // respond with a connection error (Section 5.4.1) of type
1501
+ // PROTOCOL_ERROR."
1502
+ return sc.countError("ping_on_stream", ConnectionError(ErrCodeProtocol))
1503
+ }
1504
+ sc.writeFrame(FrameWriteRequest{write: writePingAck{f}})
1505
+ return nil
1506
+ }
1507
+
1508
+ func (sc *serverConn) processWindowUpdate(f *WindowUpdateFrame) error {
1509
+ sc.serveG.check()
1510
+ switch {
1511
+ case f.StreamID != 0: // stream-level flow control
1512
+ state, st := sc.state(f.StreamID)
1513
+ if state == stateIdle {
1514
+ // Section 5.1: "Receiving any frame other than HEADERS
1515
+ // or PRIORITY on a stream in this state MUST be
1516
+ // treated as a connection error (Section 5.4.1) of
1517
+ // type PROTOCOL_ERROR."
1518
+ return sc.countError("stream_idle", ConnectionError(ErrCodeProtocol))
1519
+ }
1520
+ if st == nil {
1521
+ // "WINDOW_UPDATE can be sent by a peer that has sent a
1522
+ // frame bearing the END_STREAM flag. This means that a
1523
+ // receiver could receive a WINDOW_UPDATE frame on a "half
1524
+ // closed (remote)" or "closed" stream. A receiver MUST
1525
+ // NOT treat this as an error, see Section 5.1."
1526
+ return nil
1527
+ }
1528
+ if !st.flow.add(int32(f.Increment)) {
1529
+ return sc.countError("bad_flow", streamError(f.StreamID, ErrCodeFlowControl))
1530
+ }
1531
+ default: // connection-level flow control
1532
+ if !sc.flow.add(int32(f.Increment)) {
1533
+ return goAwayFlowError{}
1534
+ }
1535
+ }
1536
+ sc.scheduleFrameWrite()
1537
+ return nil
1538
+ }
1539
+
1540
+ func (sc *serverConn) processResetStream(f *RSTStreamFrame) error {
1541
+ sc.serveG.check()
1542
+
1543
+ state, st := sc.state(f.StreamID)
1544
+ if state == stateIdle {
1545
+ // 6.4 "RST_STREAM frames MUST NOT be sent for a
1546
+ // stream in the "idle" state. If a RST_STREAM frame
1547
+ // identifying an idle stream is received, the
1548
+ // recipient MUST treat this as a connection error
1549
+ // (Section 5.4.1) of type PROTOCOL_ERROR.
1550
+ return sc.countError("reset_idle_stream", ConnectionError(ErrCodeProtocol))
1551
+ }
1552
+ if st != nil {
1553
+ st.cancelCtx()
1554
+ sc.closeStream(st, streamError(f.StreamID, f.ErrCode))
1555
+ }
1556
+ return nil
1557
+ }
1558
+
1559
+ func (sc *serverConn) closeStream(st *stream, err error) {
1560
+ sc.serveG.check()
1561
+ if st.state == stateIdle || st.state == stateClosed {
1562
+ panic(fmt.Sprintf("invariant; can't close stream in state %v", st.state))
1563
+ }
1564
+ st.state = stateClosed
1565
+ if st.readDeadline != nil {
1566
+ st.readDeadline.Stop()
1567
+ }
1568
+ if st.writeDeadline != nil {
1569
+ st.writeDeadline.Stop()
1570
+ }
1571
+ if st.isPushed() {
1572
+ sc.curPushedStreams--
1573
+ } else {
1574
+ sc.curClientStreams--
1575
+ }
1576
+ delete(sc.streams, st.id)
1577
+ if len(sc.streams) == 0 {
1578
+ sc.setConnState(http.StateIdle)
1579
+ if sc.srv.IdleTimeout > 0 && sc.idleTimer != nil {
1580
+ sc.idleTimer.Reset(sc.srv.IdleTimeout)
1581
+ }
1582
+ if h1ServerKeepAlivesDisabled(sc.hs) {
1583
+ sc.startGracefulShutdownInternal()
1584
+ }
1585
+ }
1586
+ if p := st.body; p != nil {
1587
+ // Return any buffered unread bytes worth of conn-level flow control.
1588
+ // See golang.org/issue/16481
1589
+ sc.sendWindowUpdate(nil, p.Len())
1590
+
1591
+ p.CloseWithError(err)
1592
+ }
1593
+ if e, ok := err.(StreamError); ok {
1594
+ if e.Cause != nil {
1595
+ err = e.Cause
1596
+ } else {
1597
+ err = errStreamClosed
1598
+ }
1599
+ }
1600
+ st.closeErr = err
1601
+ st.cancelCtx()
1602
+ st.cw.Close() // signals Handler's CloseNotifier, unblocks writes, etc
1603
+ sc.writeSched.CloseStream(st.id)
1604
+ }
1605
+
1606
+ func (sc *serverConn) processSettings(f *SettingsFrame) error {
1607
+ sc.serveG.check()
1608
+ if f.IsAck() {
1609
+ sc.unackedSettings--
1610
+ if sc.unackedSettings < 0 {
1611
+ // Why is the peer ACKing settings we never sent?
1612
+ // The spec doesn't mention this case, but
1613
+ // hang up on them anyway.
1614
+ return sc.countError("ack_mystery", ConnectionError(ErrCodeProtocol))
1615
+ }
1616
+ return nil
1617
+ }
1618
+ if f.NumSettings() > 100 || f.HasDuplicates() {
1619
+ // This isn't actually in the spec, but hang up on
1620
+ // suspiciously large settings frames or those with
1621
+ // duplicate entries.
1622
+ return sc.countError("settings_big_or_dups", ConnectionError(ErrCodeProtocol))
1623
+ }
1624
+ if err := f.ForeachSetting(sc.processSetting); err != nil {
1625
+ return err
1626
+ }
1627
+ // TODO: judging by RFC 7540, Section 6.5.3 each SETTINGS frame should be
1628
+ // acknowledged individually, even if multiple are received before the ACK.
1629
+ sc.needToSendSettingsAck = true
1630
+ sc.scheduleFrameWrite()
1631
+ return nil
1632
+ }
1633
+
1634
+ func (sc *serverConn) processSetting(s Setting) error {
1635
+ sc.serveG.check()
1636
+ if err := s.Valid(); err != nil {
1637
+ return err
1638
+ }
1639
+ if VerboseLogs {
1640
+ sc.vlogf("http2: server processing setting %v", s)
1641
+ }
1642
+ switch s.ID {
1643
+ case SettingHeaderTableSize:
1644
+ sc.hpackEncoder.SetMaxDynamicTableSize(s.Val)
1645
+ case SettingEnablePush:
1646
+ sc.pushEnabled = s.Val != 0
1647
+ case SettingMaxConcurrentStreams:
1648
+ sc.clientMaxStreams = s.Val
1649
+ case SettingInitialWindowSize:
1650
+ return sc.processSettingInitialWindowSize(s.Val)
1651
+ case SettingMaxFrameSize:
1652
+ sc.maxFrameSize = int32(s.Val) // the maximum valid s.Val is < 2^31
1653
+ case SettingMaxHeaderListSize:
1654
+ sc.peerMaxHeaderListSize = s.Val
1655
+ case SettingEnableConnectProtocol:
1656
+ // Receipt of this parameter by a server does not
1657
+ // have any impact
1658
+ case SettingNoRFC7540Priorities:
1659
+ if s.Val > 1 {
1660
+ return ConnectionError(ErrCodeProtocol)
1661
+ }
1662
+ default:
1663
+ // Unknown setting: "An endpoint that receives a SETTINGS
1664
+ // frame with any unknown or unsupported identifier MUST
1665
+ // ignore that setting."
1666
+ if VerboseLogs {
1667
+ sc.vlogf("http2: server ignoring unknown setting %v", s)
1668
+ }
1669
+ }
1670
+ return nil
1671
+ }
1672
+
1673
+ func (sc *serverConn) processSettingInitialWindowSize(val uint32) error {
1674
+ sc.serveG.check()
1675
+ // Note: val already validated to be within range by
1676
+ // processSetting's Valid call.
1677
+
1678
+ // "A SETTINGS frame can alter the initial flow control window
1679
+ // size for all current streams. When the value of
1680
+ // SETTINGS_INITIAL_WINDOW_SIZE changes, a receiver MUST
1681
+ // adjust the size of all stream flow control windows that it
1682
+ // maintains by the difference between the new value and the
1683
+ // old value."
1684
+ old := sc.initialStreamSendWindowSize
1685
+ sc.initialStreamSendWindowSize = int32(val)
1686
+ growth := int32(val) - old // may be negative
1687
+ for _, st := range sc.streams {
1688
+ if !st.flow.add(growth) {
1689
+ // 6.9.2 Initial Flow Control Window Size
1690
+ // "An endpoint MUST treat a change to
1691
+ // SETTINGS_INITIAL_WINDOW_SIZE that causes any flow
1692
+ // control window to exceed the maximum size as a
1693
+ // connection error (Section 5.4.1) of type
1694
+ // FLOW_CONTROL_ERROR."
1695
+ return sc.countError("setting_win_size", ConnectionError(ErrCodeFlowControl))
1696
+ }
1697
+ }
1698
+ return nil
1699
+ }
1700
+
1701
+ func (sc *serverConn) processData(f *DataFrame) error {
1702
+ sc.serveG.check()
1703
+ id := f.Header().StreamID
1704
+
1705
+ data := f.Data()
1706
+ state, st := sc.state(id)
1707
+ if id == 0 || state == stateIdle {
1708
+ // Section 6.1: "DATA frames MUST be associated with a
1709
+ // stream. If a DATA frame is received whose stream
1710
+ // identifier field is 0x0, the recipient MUST respond
1711
+ // with a connection error (Section 5.4.1) of type
1712
+ // PROTOCOL_ERROR."
1713
+ //
1714
+ // Section 5.1: "Receiving any frame other than HEADERS
1715
+ // or PRIORITY on a stream in this state MUST be
1716
+ // treated as a connection error (Section 5.4.1) of
1717
+ // type PROTOCOL_ERROR."
1718
+ return sc.countError("data_on_idle", ConnectionError(ErrCodeProtocol))
1719
+ }
1720
+
1721
+ // "If a DATA frame is received whose stream is not in "open"
1722
+ // or "half closed (local)" state, the recipient MUST respond
1723
+ // with a stream error (Section 5.4.2) of type STREAM_CLOSED."
1724
+ if st == nil || state != stateOpen || st.gotTrailerHeader || st.resetQueued {
1725
+ // This includes sending a RST_STREAM if the stream is
1726
+ // in stateHalfClosedLocal (which currently means that
1727
+ // the http.Handler returned, so it's done reading &
1728
+ // done writing). Try to stop the client from sending
1729
+ // more DATA.
1730
+
1731
+ // But still enforce their connection-level flow control,
1732
+ // and return any flow control bytes since we're not going
1733
+ // to consume them.
1734
+ if !sc.inflow.take(f.Length) {
1735
+ return sc.countError("data_flow", streamError(id, ErrCodeFlowControl))
1736
+ }
1737
+ sc.sendWindowUpdate(nil, int(f.Length)) // conn-level
1738
+
1739
+ if st != nil && st.resetQueued {
1740
+ // Already have a stream error in flight. Don't send another.
1741
+ return nil
1742
+ }
1743
+ return sc.countError("closed", streamError(id, ErrCodeStreamClosed))
1744
+ }
1745
+ if st.body == nil {
1746
+ panic("internal error: should have a body in this state")
1747
+ }
1748
+
1749
+ // Sender sending more than they'd declared?
1750
+ if st.declBodyBytes != -1 && st.bodyBytes+int64(len(data)) > st.declBodyBytes {
1751
+ if !sc.inflow.take(f.Length) {
1752
+ return sc.countError("data_flow", streamError(id, ErrCodeFlowControl))
1753
+ }
1754
+ sc.sendWindowUpdate(nil, int(f.Length)) // conn-level
1755
+
1756
+ st.body.CloseWithError(fmt.Errorf("sender tried to send more than declared Content-Length of %d bytes", st.declBodyBytes))
1757
+ // RFC 7540, sec 8.1.2.6: A request or response is also malformed if the
1758
+ // value of a content-length header field does not equal the sum of the
1759
+ // DATA frame payload lengths that form the body.
1760
+ return sc.countError("send_too_much", streamError(id, ErrCodeProtocol))
1761
+ }
1762
+ if f.Length > 0 {
1763
+ // Check whether the client has flow control quota.
1764
+ if !takeInflows(&sc.inflow, &st.inflow, f.Length) {
1765
+ return sc.countError("flow_on_data_length", streamError(id, ErrCodeFlowControl))
1766
+ }
1767
+
1768
+ if len(data) > 0 {
1769
+ st.bodyBytes += int64(len(data))
1770
+ wrote, err := st.body.Write(data)
1771
+ if err != nil {
1772
+ // The handler has closed the request body.
1773
+ // Return the connection-level flow control for the discarded data,
1774
+ // but not the stream-level flow control.
1775
+ sc.sendWindowUpdate(nil, int(f.Length)-wrote)
1776
+ return nil
1777
+ }
1778
+ if wrote != len(data) {
1779
+ panic("internal error: bad Writer")
1780
+ }
1781
+ }
1782
+
1783
+ // Return any padded flow control now, since we won't
1784
+ // refund it later on body reads.
1785
+ // Call sendWindowUpdate even if there is no padding,
1786
+ // to return buffered flow control credit if the sent
1787
+ // window has shrunk.
1788
+ pad := int32(f.Length) - int32(len(data))
1789
+ sc.sendWindowUpdate32(nil, pad)
1790
+ sc.sendWindowUpdate32(st, pad)
1791
+ }
1792
+ if f.StreamEnded() {
1793
+ st.endStream()
1794
+ }
1795
+ return nil
1796
+ }
1797
+
1798
+ func (sc *serverConn) processGoAway(f *GoAwayFrame) error {
1799
+ sc.serveG.check()
1800
+ if f.ErrCode != ErrCodeNo {
1801
+ sc.logf("http2: received GOAWAY %+v, starting graceful shutdown", f)
1802
+ } else {
1803
+ sc.vlogf("http2: received GOAWAY %+v, starting graceful shutdown", f)
1804
+ }
1805
+ sc.startGracefulShutdownInternal()
1806
+ // http://tools.ietf.org/html/rfc7540#section-6.8
1807
+ // We should not create any new streams, which means we should disable push.
1808
+ sc.pushEnabled = false
1809
+ return nil
1810
+ }
1811
+
1812
+ // isPushed reports whether the stream is server-initiated.
1813
+ func (st *stream) isPushed() bool {
1814
+ return st.id%2 == 0
1815
+ }
1816
+
1817
+ // endStream closes a Request.Body's pipe. It is called when a DATA
1818
+ // frame says a request body is over (or after trailers).
1819
+ func (st *stream) endStream() {
1820
+ sc := st.sc
1821
+ sc.serveG.check()
1822
+
1823
+ if st.declBodyBytes != -1 && st.declBodyBytes != st.bodyBytes {
1824
+ st.body.CloseWithError(fmt.Errorf("request declared a Content-Length of %d but only wrote %d bytes",
1825
+ st.declBodyBytes, st.bodyBytes))
1826
+ } else {
1827
+ st.body.closeWithErrorAndCode(io.EOF, st.copyTrailersToHandlerRequest)
1828
+ st.body.CloseWithError(io.EOF)
1829
+ }
1830
+ st.state = stateHalfClosedRemote
1831
+ }
1832
+
1833
+ // copyTrailersToHandlerRequest is run in the Handler's goroutine in
1834
+ // its Request.Body.Read just before it gets io.EOF.
1835
+ func (st *stream) copyTrailersToHandlerRequest() {
1836
+ for k, vv := range st.trailer {
1837
+ if _, ok := st.reqTrailer[k]; ok {
1838
+ // Only copy it over it was pre-declared.
1839
+ st.reqTrailer[k] = vv
1840
+ }
1841
+ }
1842
+ }
1843
+
1844
+ // onReadTimeout is run on its own goroutine (from time.AfterFunc)
1845
+ // when the stream's ReadTimeout has fired.
1846
+ func (st *stream) onReadTimeout() {
1847
+ if st.body != nil {
1848
+ // Wrap the ErrDeadlineExceeded to avoid callers depending on us
1849
+ // returning the bare error.
1850
+ st.body.CloseWithError(fmt.Errorf("%w", os.ErrDeadlineExceeded))
1851
+ }
1852
+ }
1853
+
1854
+ // onWriteTimeout is run on its own goroutine (from time.AfterFunc)
1855
+ // when the stream's WriteTimeout has fired.
1856
+ func (st *stream) onWriteTimeout() {
1857
+ st.sc.writeFrameFromHandler(FrameWriteRequest{write: StreamError{
1858
+ StreamID: st.id,
1859
+ Code: ErrCodeInternal,
1860
+ Cause: os.ErrDeadlineExceeded,
1861
+ }})
1862
+ }
1863
+
1864
+ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error {
1865
+ sc.serveG.check()
1866
+ id := f.StreamID
1867
+ // http://tools.ietf.org/html/rfc7540#section-5.1.1
1868
+ // Streams initiated by a client MUST use odd-numbered stream
1869
+ // identifiers. [...] An endpoint that receives an unexpected
1870
+ // stream identifier MUST respond with a connection error
1871
+ // (Section 5.4.1) of type PROTOCOL_ERROR.
1872
+ if id%2 != 1 {
1873
+ return sc.countError("headers_even", ConnectionError(ErrCodeProtocol))
1874
+ }
1875
+ // A HEADERS frame can be used to create a new stream or
1876
+ // send a trailer for an open one. If we already have a stream
1877
+ // open, let it process its own HEADERS frame (trailers at this
1878
+ // point, if it's valid).
1879
+ if st := sc.streams[f.StreamID]; st != nil {
1880
+ if st.resetQueued {
1881
+ // We're sending RST_STREAM to close the stream, so don't bother
1882
+ // processing this frame.
1883
+ return nil
1884
+ }
1885
+ // RFC 7540, sec 5.1: If an endpoint receives additional frames, other than
1886
+ // WINDOW_UPDATE, PRIORITY, or RST_STREAM, for a stream that is in
1887
+ // this state, it MUST respond with a stream error (Section 5.4.2) of
1888
+ // type STREAM_CLOSED.
1889
+ if st.state == stateHalfClosedRemote {
1890
+ return sc.countError("headers_half_closed", streamError(id, ErrCodeStreamClosed))
1891
+ }
1892
+ return st.processTrailerHeaders(f)
1893
+ }
1894
+
1895
+ // [...] The identifier of a newly established stream MUST be
1896
+ // numerically greater than all streams that the initiating
1897
+ // endpoint has opened or reserved. [...] An endpoint that
1898
+ // receives an unexpected stream identifier MUST respond with
1899
+ // a connection error (Section 5.4.1) of type PROTOCOL_ERROR.
1900
+ if id <= sc.maxClientStreamID {
1901
+ return sc.countError("stream_went_down", ConnectionError(ErrCodeProtocol))
1902
+ }
1903
+ sc.maxClientStreamID = id
1904
+
1905
+ if sc.idleTimer != nil {
1906
+ sc.idleTimer.Stop()
1907
+ }
1908
+
1909
+ // http://tools.ietf.org/html/rfc7540#section-5.1.2
1910
+ // [...] Endpoints MUST NOT exceed the limit set by their peer. An
1911
+ // endpoint that receives a HEADERS frame that causes their
1912
+ // advertised concurrent stream limit to be exceeded MUST treat
1913
+ // this as a stream error (Section 5.4.2) of type PROTOCOL_ERROR
1914
+ // or REFUSED_STREAM.
1915
+ if sc.curClientStreams+1 > sc.advMaxStreams {
1916
+ if sc.unackedSettings == 0 {
1917
+ // They should know better.
1918
+ return sc.countError("over_max_streams", streamError(id, ErrCodeProtocol))
1919
+ }
1920
+ // Assume it's a network race, where they just haven't
1921
+ // received our last SETTINGS update. But actually
1922
+ // this can't happen yet, because we don't yet provide
1923
+ // a way for users to adjust server parameters at
1924
+ // runtime.
1925
+ return sc.countError("over_max_streams_race", streamError(id, ErrCodeRefusedStream))
1926
+ }
1927
+
1928
+ initialState := stateOpen
1929
+ if f.StreamEnded() {
1930
+ initialState = stateHalfClosedRemote
1931
+ }
1932
+
1933
+ // We are handling two special cases here:
1934
+ // 1. When a request is sent via an intermediary, we force priority to be
1935
+ // u=3,i. This is essentially a round-robin behavior, and is done to ensure
1936
+ // fairness between, for example, multiple clients using the same proxy.
1937
+ // 2. Until a client has shown that it is aware of RFC 9218, we make its
1938
+ // streams non-incremental by default. This is done to preserve the
1939
+ // historical behavior of handling streams in a round-robin manner, rather
1940
+ // than one-by-one to completion.
1941
+ initialPriority := defaultRFC9218Priority(sc.priorityAware && !sc.hasIntermediary)
1942
+ if _, ok := sc.writeSched.(*priorityWriteSchedulerRFC9218); ok && !sc.hasIntermediary {
1943
+ headerPriority, priorityAware, hasIntermediary := f.rfc9218Priority(sc.priorityAware)
1944
+ initialPriority = headerPriority
1945
+ sc.hasIntermediary = hasIntermediary
1946
+ if priorityAware {
1947
+ sc.priorityAware = true
1948
+ }
1949
+ }
1950
+ st := sc.newStream(id, 0, initialState, initialPriority)
1951
+
1952
+ if f.HasPriority() {
1953
+ if err := sc.checkPriority(f.StreamID, f.Priority); err != nil {
1954
+ return err
1955
+ }
1956
+ if !sc.writeSchedIgnoresRFC7540() {
1957
+ sc.writeSched.AdjustStream(st.id, f.Priority)
1958
+ }
1959
+ }
1960
+
1961
+ rw, req, err := sc.newWriterAndRequest(st, f)
1962
+ if err != nil {
1963
+ return err
1964
+ }
1965
+ st.reqTrailer = req.Trailer
1966
+ if st.reqTrailer != nil {
1967
+ st.trailer = make(http.Header)
1968
+ }
1969
+ st.body = req.Body.(*requestBody).pipe // may be nil
1970
+ st.declBodyBytes = req.ContentLength
1971
+
1972
+ handler := sc.handler.ServeHTTP
1973
+ if f.Truncated {
1974
+ // Their header list was too long. Send a 431 error.
1975
+ handler = handleHeaderListTooLong
1976
+ } else if err := checkValidHTTP2RequestHeaders(req.Header); err != nil {
1977
+ handler = new400Handler(err)
1978
+ }
1979
+
1980
+ // The net/http package sets the read deadline from the
1981
+ // http.Server.ReadTimeout during the TLS handshake, but then
1982
+ // passes the connection off to us with the deadline already
1983
+ // set. Disarm it here after the request headers are read,
1984
+ // similar to how the http1 server works. Here it's
1985
+ // technically more like the http1 Server's ReadHeaderTimeout
1986
+ // (in Go 1.8), though. That's a more sane option anyway.
1987
+ if sc.hs.ReadTimeout > 0 {
1988
+ sc.conn.SetReadDeadline(time.Time{})
1989
+ st.readDeadline = time.AfterFunc(sc.hs.ReadTimeout, st.onReadTimeout)
1990
+ }
1991
+
1992
+ return sc.scheduleHandler(id, rw, req, handler)
1993
+ }
1994
+
1995
+ func (sc *serverConn) upgradeRequest(req *http.Request) {
1996
+ sc.serveG.check()
1997
+ id := uint32(1)
1998
+ sc.maxClientStreamID = id
1999
+ st := sc.newStream(id, 0, stateHalfClosedRemote, defaultRFC9218Priority(sc.priorityAware && !sc.hasIntermediary))
2000
+ st.reqTrailer = req.Trailer
2001
+ if st.reqTrailer != nil {
2002
+ st.trailer = make(http.Header)
2003
+ }
2004
+ rw := sc.newResponseWriter(st, req)
2005
+
2006
+ // Disable any read deadline set by the net/http package
2007
+ // prior to the upgrade.
2008
+ if sc.hs.ReadTimeout > 0 {
2009
+ sc.conn.SetReadDeadline(time.Time{})
2010
+ }
2011
+
2012
+ // This is the first request on the connection,
2013
+ // so start the handler directly rather than going
2014
+ // through scheduleHandler.
2015
+ sc.curHandlers++
2016
+ go sc.runHandler(rw, req, sc.handler.ServeHTTP)
2017
+ }
2018
+
2019
+ func (st *stream) processTrailerHeaders(f *MetaHeadersFrame) error {
2020
+ sc := st.sc
2021
+ sc.serveG.check()
2022
+ if st.gotTrailerHeader {
2023
+ return sc.countError("dup_trailers", ConnectionError(ErrCodeProtocol))
2024
+ }
2025
+ st.gotTrailerHeader = true
2026
+ if !f.StreamEnded() {
2027
+ return sc.countError("trailers_not_ended", streamError(st.id, ErrCodeProtocol))
2028
+ }
2029
+
2030
+ if len(f.PseudoFields()) > 0 {
2031
+ return sc.countError("trailers_pseudo", streamError(st.id, ErrCodeProtocol))
2032
+ }
2033
+ if st.trailer != nil {
2034
+ for _, hf := range f.RegularFields() {
2035
+ key := sc.canonicalHeader(hf.Name)
2036
+ if !httpguts.ValidTrailerHeader(key) {
2037
+ // TODO: send more details to the peer somehow. But http2 has
2038
+ // no way to send debug data at a stream level. Discuss with
2039
+ // HTTP folk.
2040
+ return sc.countError("trailers_bogus", streamError(st.id, ErrCodeProtocol))
2041
+ }
2042
+ st.trailer[key] = append(st.trailer[key], hf.Value)
2043
+ }
2044
+ }
2045
+ st.endStream()
2046
+ return nil
2047
+ }
2048
+
2049
+ func (sc *serverConn) checkPriority(streamID uint32, p PriorityParam) error {
2050
+ if streamID == p.StreamDep {
2051
+ // Section 5.3.1: "A stream cannot depend on itself. An endpoint MUST treat
2052
+ // this as a stream error (Section 5.4.2) of type PROTOCOL_ERROR."
2053
+ // Section 5.3.3 says that a stream can depend on one of its dependencies,
2054
+ // so it's only self-dependencies that are forbidden.
2055
+ return sc.countError("priority", streamError(streamID, ErrCodeProtocol))
2056
+ }
2057
+ return nil
2058
+ }
2059
+
2060
+ func (sc *serverConn) processPriority(f *PriorityFrame) error {
2061
+ if err := sc.checkPriority(f.StreamID, f.PriorityParam); err != nil {
2062
+ return err
2063
+ }
2064
+ // We need to avoid calling AdjustStream when using the RFC 9218 write
2065
+ // scheduler. Otherwise, incremental's zero value in PriorityParam will
2066
+ // unexpectedly make all streams non-incremental. This causes us to process
2067
+ // streams one-by-one to completion rather than doing it in a round-robin
2068
+ // manner (the historical behavior), which might be unexpected to users.
2069
+ if sc.writeSchedIgnoresRFC7540() {
2070
+ return nil
2071
+ }
2072
+ sc.writeSched.AdjustStream(f.StreamID, f.PriorityParam)
2073
+ return nil
2074
+ }
2075
+
2076
+ func (sc *serverConn) processPriorityUpdate(f *PriorityUpdateFrame) error {
2077
+ sc.priorityAware = true
2078
+ if _, ok := sc.writeSched.(*priorityWriteSchedulerRFC9218); !ok {
2079
+ return nil
2080
+ }
2081
+ p, ok := parseRFC9218Priority(f.Priority, sc.priorityAware)
2082
+ if !ok {
2083
+ return sc.countError("unparsable_priority_update", streamError(f.PrioritizedStreamID, ErrCodeProtocol))
2084
+ }
2085
+ sc.writeSched.AdjustStream(f.PrioritizedStreamID, p)
2086
+ return nil
2087
+ }
2088
+
2089
+ func (sc *serverConn) newStream(id, pusherID uint32, state streamState, priority PriorityParam) *stream {
2090
+ sc.serveG.check()
2091
+ if id == 0 {
2092
+ panic("internal error: cannot create stream with id 0")
2093
+ }
2094
+
2095
+ ctx, cancelCtx := context.WithCancel(sc.baseCtx)
2096
+ st := &stream{
2097
+ sc: sc,
2098
+ id: id,
2099
+ state: state,
2100
+ ctx: ctx,
2101
+ cancelCtx: cancelCtx,
2102
+ }
2103
+ st.cw.Init()
2104
+ st.flow.conn = &sc.flow // link to conn-level counter
2105
+ st.flow.add(sc.initialStreamSendWindowSize)
2106
+ st.inflow.init(sc.initialStreamRecvWindowSize)
2107
+ if sc.hs.WriteTimeout > 0 {
2108
+ st.writeDeadline = time.AfterFunc(sc.hs.WriteTimeout, st.onWriteTimeout)
2109
+ }
2110
+
2111
+ sc.streams[id] = st
2112
+ sc.writeSched.OpenStream(st.id, OpenStreamOptions{PusherID: pusherID, priority: priority})
2113
+ if st.isPushed() {
2114
+ sc.curPushedStreams++
2115
+ } else {
2116
+ sc.curClientStreams++
2117
+ }
2118
+ if sc.curOpenStreams() == 1 {
2119
+ sc.setConnState(http.StateActive)
2120
+ }
2121
+
2122
+ return st
2123
+ }
2124
+
2125
+ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*responseWriter, *http.Request, error) {
2126
+ sc.serveG.check()
2127
+
2128
+ rp := httpcommon.ServerRequestParam{
2129
+ Method: f.PseudoValue("method"),
2130
+ Scheme: f.PseudoValue("scheme"),
2131
+ Authority: f.PseudoValue("authority"),
2132
+ Path: f.PseudoValue("path"),
2133
+ Protocol: f.PseudoValue("protocol"),
2134
+ }
2135
+
2136
+ // extended connect is disabled, so we should not see :protocol
2137
+ if disableExtendedConnectProtocol && rp.Protocol != "" {
2138
+ return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol))
2139
+ }
2140
+
2141
+ isConnect := rp.Method == "CONNECT"
2142
+ if isConnect {
2143
+ if rp.Protocol == "" && (rp.Path != "" || rp.Scheme != "" || rp.Authority == "") {
2144
+ return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol))
2145
+ }
2146
+ } else if rp.Method == "" || rp.Path == "" || (rp.Scheme != "https" && rp.Scheme != "http") {
2147
+ // See 8.1.2.6 Malformed Requests and Responses:
2148
+ //
2149
+ // Malformed requests or responses that are detected
2150
+ // MUST be treated as a stream error (Section 5.4.2)
2151
+ // of type PROTOCOL_ERROR."
2152
+ //
2153
+ // 8.1.2.3 Request Pseudo-Header Fields
2154
+ // "All HTTP/2 requests MUST include exactly one valid
2155
+ // value for the :method, :scheme, and :path
2156
+ // pseudo-header fields"
2157
+ return nil, nil, sc.countError("bad_path_method", streamError(f.StreamID, ErrCodeProtocol))
2158
+ }
2159
+
2160
+ header := make(http.Header)
2161
+ rp.Header = header
2162
+ for _, hf := range f.RegularFields() {
2163
+ header.Add(sc.canonicalHeader(hf.Name), hf.Value)
2164
+ }
2165
+ if rp.Authority == "" {
2166
+ rp.Authority = header.Get("Host")
2167
+ }
2168
+ if rp.Protocol != "" {
2169
+ header.Set(":protocol", rp.Protocol)
2170
+ }
2171
+
2172
+ rw, req, err := sc.newWriterAndRequestNoBody(st, rp)
2173
+ if err != nil {
2174
+ return nil, nil, err
2175
+ }
2176
+ bodyOpen := !f.StreamEnded()
2177
+ if bodyOpen {
2178
+ if vv, ok := rp.Header["Content-Length"]; ok {
2179
+ if cl, err := strconv.ParseUint(vv[0], 10, 63); err == nil {
2180
+ req.ContentLength = int64(cl)
2181
+ } else {
2182
+ req.ContentLength = 0
2183
+ }
2184
+ } else {
2185
+ req.ContentLength = -1
2186
+ }
2187
+ req.Body.(*requestBody).pipe = &pipe{
2188
+ b: &dataBuffer{expected: req.ContentLength},
2189
+ }
2190
+ }
2191
+ return rw, req, nil
2192
+ }
2193
+
2194
+ func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp httpcommon.ServerRequestParam) (*responseWriter, *http.Request, error) {
2195
+ sc.serveG.check()
2196
+
2197
+ var tlsState *tls.ConnectionState // nil if not scheme https
2198
+ if rp.Scheme == "https" {
2199
+ tlsState = sc.tlsState
2200
+ }
2201
+
2202
+ res := httpcommon.NewServerRequest(rp)
2203
+ if res.InvalidReason != "" {
2204
+ return nil, nil, sc.countError(res.InvalidReason, streamError(st.id, ErrCodeProtocol))
2205
+ }
2206
+
2207
+ body := &requestBody{
2208
+ conn: sc,
2209
+ stream: st,
2210
+ needsContinue: res.NeedsContinue,
2211
+ }
2212
+ req := (&http.Request{
2213
+ Method: rp.Method,
2214
+ URL: res.URL,
2215
+ RemoteAddr: sc.remoteAddrStr,
2216
+ Header: rp.Header,
2217
+ RequestURI: res.RequestURI,
2218
+ Proto: "HTTP/2.0",
2219
+ ProtoMajor: 2,
2220
+ ProtoMinor: 0,
2221
+ TLS: tlsState,
2222
+ Host: rp.Authority,
2223
+ Body: body,
2224
+ Trailer: res.Trailer,
2225
+ }).WithContext(st.ctx)
2226
+ rw := sc.newResponseWriter(st, req)
2227
+ return rw, req, nil
2228
+ }
2229
+
2230
+ func (sc *serverConn) newResponseWriter(st *stream, req *http.Request) *responseWriter {
2231
+ rws := responseWriterStatePool.Get().(*responseWriterState)
2232
+ bwSave := rws.bw
2233
+ *rws = responseWriterState{} // zero all the fields
2234
+ rws.conn = sc
2235
+ rws.bw = bwSave
2236
+ rws.bw.Reset(chunkWriter{rws})
2237
+ rws.stream = st
2238
+ rws.req = req
2239
+ return &responseWriter{rws: rws}
2240
+ }
2241
+
2242
+ type unstartedHandler struct {
2243
+ streamID uint32
2244
+ rw *responseWriter
2245
+ req *http.Request
2246
+ handler func(http.ResponseWriter, *http.Request)
2247
+ }
2248
+
2249
+ // scheduleHandler starts a handler goroutine,
2250
+ // or schedules one to start as soon as an existing handler finishes.
2251
+ func (sc *serverConn) scheduleHandler(streamID uint32, rw *responseWriter, req *http.Request, handler func(http.ResponseWriter, *http.Request)) error {
2252
+ sc.serveG.check()
2253
+ maxHandlers := sc.advMaxStreams
2254
+ if sc.curHandlers < maxHandlers {
2255
+ sc.curHandlers++
2256
+ go sc.runHandler(rw, req, handler)
2257
+ return nil
2258
+ }
2259
+ if len(sc.unstartedHandlers) > int(4*sc.advMaxStreams) {
2260
+ return sc.countError("too_many_early_resets", ConnectionError(ErrCodeEnhanceYourCalm))
2261
+ }
2262
+ sc.unstartedHandlers = append(sc.unstartedHandlers, unstartedHandler{
2263
+ streamID: streamID,
2264
+ rw: rw,
2265
+ req: req,
2266
+ handler: handler,
2267
+ })
2268
+ return nil
2269
+ }
2270
+
2271
+ func (sc *serverConn) handlerDone() {
2272
+ sc.serveG.check()
2273
+ sc.curHandlers--
2274
+ i := 0
2275
+ maxHandlers := sc.advMaxStreams
2276
+ for ; i < len(sc.unstartedHandlers); i++ {
2277
+ u := sc.unstartedHandlers[i]
2278
+ if sc.streams[u.streamID] == nil {
2279
+ // This stream was reset before its goroutine had a chance to start.
2280
+ continue
2281
+ }
2282
+ if sc.curHandlers >= maxHandlers {
2283
+ break
2284
+ }
2285
+ sc.curHandlers++
2286
+ go sc.runHandler(u.rw, u.req, u.handler)
2287
+ sc.unstartedHandlers[i] = unstartedHandler{} // don't retain references
2288
+ }
2289
+ sc.unstartedHandlers = sc.unstartedHandlers[i:]
2290
+ if len(sc.unstartedHandlers) == 0 {
2291
+ sc.unstartedHandlers = nil
2292
+ }
2293
+ }
2294
+
2295
+ // Run on its own goroutine.
2296
+ func (sc *serverConn) runHandler(rw *responseWriter, req *http.Request, handler func(http.ResponseWriter, *http.Request)) {
2297
+ defer sc.sendServeMsg(handlerDoneMsg)
2298
+ didPanic := true
2299
+ defer func() {
2300
+ rw.rws.stream.cancelCtx()
2301
+ if req.MultipartForm != nil {
2302
+ req.MultipartForm.RemoveAll()
2303
+ }
2304
+ if didPanic {
2305
+ e := recover()
2306
+ sc.writeFrameFromHandler(FrameWriteRequest{
2307
+ write: handlerPanicRST{rw.rws.stream.id},
2308
+ stream: rw.rws.stream,
2309
+ })
2310
+ // Same as net/http:
2311
+ if e != nil && e != http.ErrAbortHandler {
2312
+ const size = 64 << 10
2313
+ buf := make([]byte, size)
2314
+ buf = buf[:runtime.Stack(buf, false)]
2315
+ sc.logf("http2: panic serving %v: %v\n%s", sc.conn.RemoteAddr(), e, buf)
2316
+ }
2317
+ return
2318
+ }
2319
+ rw.handlerDone()
2320
+ }()
2321
+ handler(rw, req)
2322
+ didPanic = false
2323
+ }
2324
+
2325
+ func handleHeaderListTooLong(w http.ResponseWriter, r *http.Request) {
2326
+ // 10.5.1 Limits on Header Block Size:
2327
+ // .. "A server that receives a larger header block than it is
2328
+ // willing to handle can send an HTTP 431 (Request Header Fields Too
2329
+ // Large) status code"
2330
+ const statusRequestHeaderFieldsTooLarge = 431 // only in Go 1.6+
2331
+ w.WriteHeader(statusRequestHeaderFieldsTooLarge)
2332
+ io.WriteString(w, "<h1>HTTP Error 431</h1><p>Request Header Field(s) Too Large</p>")
2333
+ }
2334
+
2335
+ // called from handler goroutines.
2336
+ // h may be nil.
2337
+ func (sc *serverConn) writeHeaders(st *stream, headerData *writeResHeaders) error {
2338
+ sc.serveG.checkNotOn() // NOT on
2339
+ var errc chan error
2340
+ if headerData.h != nil {
2341
+ // If there's a header map (which we don't own), so we have to block on
2342
+ // waiting for this frame to be written, so an http.Flush mid-handler
2343
+ // writes out the correct value of keys, before a handler later potentially
2344
+ // mutates it.
2345
+ errc = sc.srv.state.getErrChan()
2346
+ }
2347
+ if err := sc.writeFrameFromHandler(FrameWriteRequest{
2348
+ write: headerData,
2349
+ stream: st,
2350
+ done: errc,
2351
+ }); err != nil {
2352
+ return err
2353
+ }
2354
+ if errc != nil {
2355
+ select {
2356
+ case err := <-errc:
2357
+ sc.srv.state.putErrChan(errc)
2358
+ return err
2359
+ case <-sc.doneServing:
2360
+ return errClientDisconnected
2361
+ case <-st.cw:
2362
+ return errStreamClosed
2363
+ }
2364
+ }
2365
+ return nil
2366
+ }
2367
+
2368
+ // called from handler goroutines.
2369
+ func (sc *serverConn) write100ContinueHeaders(st *stream) {
2370
+ sc.writeFrameFromHandler(FrameWriteRequest{
2371
+ write: write100ContinueHeadersFrame{st.id},
2372
+ stream: st,
2373
+ })
2374
+ }
2375
+
2376
+ // A bodyReadMsg tells the server loop that the http.Handler read n
2377
+ // bytes of the DATA from the client on the given stream.
2378
+ type bodyReadMsg struct {
2379
+ st *stream
2380
+ n int
2381
+ }
2382
+
2383
+ // called from handler goroutines.
2384
+ // Notes that the handler for the given stream ID read n bytes of its body
2385
+ // and schedules flow control tokens to be sent.
2386
+ func (sc *serverConn) noteBodyReadFromHandler(st *stream, n int, err error) {
2387
+ sc.serveG.checkNotOn() // NOT on
2388
+ if n > 0 {
2389
+ select {
2390
+ case sc.bodyReadCh <- bodyReadMsg{st, n}:
2391
+ case <-sc.doneServing:
2392
+ }
2393
+ }
2394
+ }
2395
+
2396
+ func (sc *serverConn) noteBodyRead(st *stream, n int) {
2397
+ sc.serveG.check()
2398
+ sc.sendWindowUpdate(nil, n) // conn-level
2399
+ if st.state != stateHalfClosedRemote && st.state != stateClosed {
2400
+ // Don't send this WINDOW_UPDATE if the stream is closed
2401
+ // remotely.
2402
+ sc.sendWindowUpdate(st, n)
2403
+ }
2404
+ }
2405
+
2406
+ // st may be nil for conn-level
2407
+ func (sc *serverConn) sendWindowUpdate32(st *stream, n int32) {
2408
+ sc.sendWindowUpdate(st, int(n))
2409
+ }
2410
+
2411
+ // st may be nil for conn-level
2412
+ func (sc *serverConn) sendWindowUpdate(st *stream, n int) {
2413
+ sc.serveG.check()
2414
+ var streamID uint32
2415
+ var send int32
2416
+ if st == nil {
2417
+ send = sc.inflow.add(n)
2418
+ } else {
2419
+ streamID = st.id
2420
+ send = st.inflow.add(n)
2421
+ }
2422
+ if send == 0 {
2423
+ return
2424
+ }
2425
+ sc.writeFrame(FrameWriteRequest{
2426
+ write: writeWindowUpdate{streamID: streamID, n: uint32(send)},
2427
+ stream: st,
2428
+ })
2429
+ }
2430
+
2431
+ // requestBody is the Handler's Request.Body type.
2432
+ // Read and Close may be called concurrently.
2433
+ type requestBody struct {
2434
+ _ incomparable
2435
+ stream *stream
2436
+ conn *serverConn
2437
+ closeOnce sync.Once // for use by Close only
2438
+ sawEOF bool // for use by Read only
2439
+ pipe *pipe // non-nil if we have an HTTP entity message body
2440
+ needsContinue bool // need to send a 100-continue
2441
+ }
2442
+
2443
+ func (b *requestBody) Close() error {
2444
+ b.closeOnce.Do(func() {
2445
+ if b.pipe != nil {
2446
+ b.pipe.BreakWithError(errClosedBody)
2447
+ }
2448
+ })
2449
+ return nil
2450
+ }
2451
+
2452
+ func (b *requestBody) Read(p []byte) (n int, err error) {
2453
+ if b.needsContinue {
2454
+ b.needsContinue = false
2455
+ b.conn.write100ContinueHeaders(b.stream)
2456
+ }
2457
+ if b.pipe == nil || b.sawEOF {
2458
+ return 0, io.EOF
2459
+ }
2460
+ n, err = b.pipe.Read(p)
2461
+ if err == io.EOF {
2462
+ b.sawEOF = true
2463
+ }
2464
+ if b.conn == nil {
2465
+ return
2466
+ }
2467
+ b.conn.noteBodyReadFromHandler(b.stream, n, err)
2468
+ return
2469
+ }
2470
+
2471
+ // responseWriter is the http.ResponseWriter implementation. It's
2472
+ // intentionally small (1 pointer wide) to minimize garbage. The
2473
+ // responseWriterState pointer inside is zeroed at the end of a
2474
+ // request (in handlerDone) and calls on the responseWriter thereafter
2475
+ // simply crash (caller's mistake), but the much larger responseWriterState
2476
+ // and buffers are reused between multiple requests.
2477
+ type responseWriter struct {
2478
+ rws *responseWriterState
2479
+ }
2480
+
2481
+ // Optional http.ResponseWriter interfaces implemented.
2482
+ var (
2483
+ _ http.CloseNotifier = (*responseWriter)(nil)
2484
+ _ http.Flusher = (*responseWriter)(nil)
2485
+ _ stringWriter = (*responseWriter)(nil)
2486
+ )
2487
+
2488
+ type responseWriterState struct {
2489
+ // immutable within a request:
2490
+ stream *stream
2491
+ req *http.Request
2492
+ conn *serverConn
2493
+
2494
+ // TODO: adjust buffer writing sizes based on server config, frame size updates from peer, etc
2495
+ bw *bufio.Writer // writing to a chunkWriter{this *responseWriterState}
2496
+
2497
+ // mutated by http.Handler goroutine:
2498
+ handlerHeader http.Header // nil until called
2499
+ snapHeader http.Header // snapshot of handlerHeader at WriteHeader time
2500
+ trailers []string // set in writeChunk
2501
+ status int // status code passed to WriteHeader
2502
+ wroteHeader bool // WriteHeader called (explicitly or implicitly). Not necessarily sent to user yet.
2503
+ sentHeader bool // have we sent the header frame?
2504
+ handlerDone bool // handler has finished
2505
+
2506
+ sentContentLen int64 // non-zero if handler set a Content-Length header
2507
+ wroteBytes int64
2508
+
2509
+ closeNotifierMu sync.Mutex // guards closeNotifierCh
2510
+ closeNotifierCh chan bool // nil until first used
2511
+ }
2512
+
2513
+ type chunkWriter struct{ rws *responseWriterState }
2514
+
2515
+ func (cw chunkWriter) Write(p []byte) (n int, err error) {
2516
+ n, err = cw.rws.writeChunk(p)
2517
+ if err == errStreamClosed {
2518
+ // If writing failed because the stream has been closed,
2519
+ // return the reason it was closed.
2520
+ err = cw.rws.stream.closeErr
2521
+ }
2522
+ return n, err
2523
+ }
2524
+
2525
+ func (rws *responseWriterState) hasTrailers() bool { return len(rws.trailers) > 0 }
2526
+
2527
+ func (rws *responseWriterState) hasNonemptyTrailers() bool {
2528
+ for _, trailer := range rws.trailers {
2529
+ if _, ok := rws.handlerHeader[trailer]; ok {
2530
+ return true
2531
+ }
2532
+ }
2533
+ return false
2534
+ }
2535
+
2536
+ // declareTrailer is called for each Trailer header when the
2537
+ // response header is written. It notes that a header will need to be
2538
+ // written in the trailers at the end of the response.
2539
+ func (rws *responseWriterState) declareTrailer(k string) {
2540
+ k = http.CanonicalHeaderKey(k)
2541
+ if !httpguts.ValidTrailerHeader(k) {
2542
+ // Forbidden by RFC 7230, section 4.1.2.
2543
+ rws.conn.logf("ignoring invalid trailer %q", k)
2544
+ return
2545
+ }
2546
+ if !strSliceContains(rws.trailers, k) {
2547
+ rws.trailers = append(rws.trailers, k)
2548
+ }
2549
+ }
2550
+
2551
+ // writeChunk writes chunks from the bufio.Writer. But because
2552
+ // bufio.Writer may bypass its chunking, sometimes p may be
2553
+ // arbitrarily large.
2554
+ //
2555
+ // writeChunk is also responsible (on the first chunk) for sending the
2556
+ // HEADER response.
2557
+ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) {
2558
+ if !rws.wroteHeader {
2559
+ rws.writeHeader(200)
2560
+ }
2561
+
2562
+ if rws.handlerDone {
2563
+ rws.promoteUndeclaredTrailers()
2564
+ }
2565
+
2566
+ isHeadResp := rws.req.Method == "HEAD"
2567
+ if !rws.sentHeader {
2568
+ rws.sentHeader = true
2569
+ var ctype, clen string
2570
+ if clen = rws.snapHeader.Get("Content-Length"); clen != "" {
2571
+ rws.snapHeader.Del("Content-Length")
2572
+ if cl, err := strconv.ParseUint(clen, 10, 63); err == nil {
2573
+ rws.sentContentLen = int64(cl)
2574
+ } else {
2575
+ clen = ""
2576
+ }
2577
+ }
2578
+ _, hasContentLength := rws.snapHeader["Content-Length"]
2579
+ if !hasContentLength && clen == "" && rws.handlerDone && bodyAllowedForStatus(rws.status) && (len(p) > 0 || !isHeadResp) {
2580
+ clen = strconv.Itoa(len(p))
2581
+ }
2582
+ _, hasContentType := rws.snapHeader["Content-Type"]
2583
+ // If the Content-Encoding is non-blank, we shouldn't
2584
+ // sniff the body. See Issue golang.org/issue/31753.
2585
+ ce := rws.snapHeader.Get("Content-Encoding")
2586
+ hasCE := len(ce) > 0
2587
+ if !hasCE && !hasContentType && bodyAllowedForStatus(rws.status) && len(p) > 0 {
2588
+ ctype = http.DetectContentType(p)
2589
+ }
2590
+ var date string
2591
+ if _, ok := rws.snapHeader["Date"]; !ok {
2592
+ // TODO(bradfitz): be faster here, like net/http? measure.
2593
+ date = time.Now().UTC().Format(http.TimeFormat)
2594
+ }
2595
+
2596
+ for _, v := range rws.snapHeader["Trailer"] {
2597
+ foreachHeaderElement(v, rws.declareTrailer)
2598
+ }
2599
+
2600
+ // "Connection" headers aren't allowed in HTTP/2 (RFC 7540, 8.1.2.2),
2601
+ // but respect "Connection" == "close" to mean sending a GOAWAY and tearing
2602
+ // down the TCP connection when idle, like we do for HTTP/1.
2603
+ // TODO: remove more Connection-specific header fields here, in addition
2604
+ // to "Connection".
2605
+ if _, ok := rws.snapHeader["Connection"]; ok {
2606
+ v := rws.snapHeader.Get("Connection")
2607
+ delete(rws.snapHeader, "Connection")
2608
+ if v == "close" {
2609
+ rws.conn.startGracefulShutdown()
2610
+ }
2611
+ }
2612
+
2613
+ endStream := (rws.handlerDone && !rws.hasTrailers() && len(p) == 0) || isHeadResp
2614
+ err = rws.conn.writeHeaders(rws.stream, &writeResHeaders{
2615
+ streamID: rws.stream.id,
2616
+ httpResCode: rws.status,
2617
+ h: rws.snapHeader,
2618
+ endStream: endStream,
2619
+ contentType: ctype,
2620
+ contentLength: clen,
2621
+ date: date,
2622
+ })
2623
+ if err != nil {
2624
+ return 0, err
2625
+ }
2626
+ if endStream {
2627
+ return 0, nil
2628
+ }
2629
+ }
2630
+ if isHeadResp {
2631
+ return len(p), nil
2632
+ }
2633
+ if len(p) == 0 && !rws.handlerDone {
2634
+ return 0, nil
2635
+ }
2636
+
2637
+ // only send trailers if they have actually been defined by the
2638
+ // server handler.
2639
+ hasNonemptyTrailers := rws.hasNonemptyTrailers()
2640
+ endStream := rws.handlerDone && !hasNonemptyTrailers
2641
+ if len(p) > 0 || endStream {
2642
+ // only send a 0 byte DATA frame if we're ending the stream.
2643
+ if err := rws.conn.writeDataFromHandler(rws.stream, p, endStream); err != nil {
2644
+ return 0, err
2645
+ }
2646
+ }
2647
+
2648
+ if rws.handlerDone && hasNonemptyTrailers {
2649
+ err = rws.conn.writeHeaders(rws.stream, &writeResHeaders{
2650
+ streamID: rws.stream.id,
2651
+ h: rws.handlerHeader,
2652
+ trailers: rws.trailers,
2653
+ endStream: true,
2654
+ })
2655
+ return len(p), err
2656
+ }
2657
+ return len(p), nil
2658
+ }
2659
+
2660
+ // promoteUndeclaredTrailers permits http.Handlers to set trailers
2661
+ // after the header has already been flushed. Because the Go
2662
+ // ResponseWriter interface has no way to set Trailers (only the
2663
+ // Header), and because we didn't want to expand the ResponseWriter
2664
+ // interface, and because nobody used trailers, and because RFC 7230
2665
+ // says you SHOULD (but not must) predeclare any trailers in the
2666
+ // header, the official ResponseWriter rules said trailers in Go must
2667
+ // be predeclared, and then we reuse the same ResponseWriter.Header()
2668
+ // map to mean both Headers and Trailers. When it's time to write the
2669
+ // Trailers, we pick out the fields of Headers that were declared as
2670
+ // trailers. That worked for a while, until we found the first major
2671
+ // user of Trailers in the wild: gRPC (using them only over http2),
2672
+ // and gRPC libraries permit setting trailers mid-stream without
2673
+ // predeclaring them. So: change of plans. We still permit the old
2674
+ // way, but we also permit this hack: if a Header() key begins with
2675
+ // "Trailer:", the suffix of that key is a Trailer. Because ':' is an
2676
+ // invalid token byte anyway, there is no ambiguity. (And it's already
2677
+ // filtered out) It's mildly hacky, but not terrible.
2678
+ //
2679
+ // This method runs after the Handler is done and promotes any Header
2680
+ // fields to be trailers.
2681
+ func (rws *responseWriterState) promoteUndeclaredTrailers() {
2682
+ for k, vv := range rws.handlerHeader {
2683
+ if !strings.HasPrefix(k, TrailerPrefix) {
2684
+ continue
2685
+ }
2686
+ trailerKey := strings.TrimPrefix(k, TrailerPrefix)
2687
+ rws.declareTrailer(trailerKey)
2688
+ rws.handlerHeader[http.CanonicalHeaderKey(trailerKey)] = vv
2689
+ }
2690
+
2691
+ if len(rws.trailers) > 1 {
2692
+ sorter := sorterPool.Get().(*sorter)
2693
+ sorter.SortStrings(rws.trailers)
2694
+ sorterPool.Put(sorter)
2695
+ }
2696
+ }
2697
+
2698
+ func (w *responseWriter) SetReadDeadline(deadline time.Time) error {
2699
+ st := w.rws.stream
2700
+ if !deadline.IsZero() && deadline.Before(time.Now()) {
2701
+ // If we're setting a deadline in the past, reset the stream immediately
2702
+ // so writes after SetWriteDeadline returns will fail.
2703
+ st.onReadTimeout()
2704
+ return nil
2705
+ }
2706
+ w.rws.conn.sendServeMsg(func(sc *serverConn) {
2707
+ if st.readDeadline != nil {
2708
+ if !st.readDeadline.Stop() {
2709
+ // Deadline already exceeded, or stream has been closed.
2710
+ return
2711
+ }
2712
+ }
2713
+ if deadline.IsZero() {
2714
+ st.readDeadline = nil
2715
+ } else if st.readDeadline == nil {
2716
+ st.readDeadline = time.AfterFunc(deadline.Sub(time.Now()), st.onReadTimeout)
2717
+ } else {
2718
+ st.readDeadline.Reset(deadline.Sub(time.Now()))
2719
+ }
2720
+ })
2721
+ return nil
2722
+ }
2723
+
2724
+ func (w *responseWriter) SetWriteDeadline(deadline time.Time) error {
2725
+ st := w.rws.stream
2726
+ if !deadline.IsZero() && deadline.Before(time.Now()) {
2727
+ // If we're setting a deadline in the past, reset the stream immediately
2728
+ // so writes after SetWriteDeadline returns will fail.
2729
+ st.onWriteTimeout()
2730
+ return nil
2731
+ }
2732
+ w.rws.conn.sendServeMsg(func(sc *serverConn) {
2733
+ if st.writeDeadline != nil {
2734
+ if !st.writeDeadline.Stop() {
2735
+ // Deadline already exceeded, or stream has been closed.
2736
+ return
2737
+ }
2738
+ }
2739
+ if deadline.IsZero() {
2740
+ st.writeDeadline = nil
2741
+ } else if st.writeDeadline == nil {
2742
+ st.writeDeadline = time.AfterFunc(deadline.Sub(time.Now()), st.onWriteTimeout)
2743
+ } else {
2744
+ st.writeDeadline.Reset(deadline.Sub(time.Now()))
2745
+ }
2746
+ })
2747
+ return nil
2748
+ }
2749
+
2750
+ func (w *responseWriter) EnableFullDuplex() error {
2751
+ // We always support full duplex responses, so this is a no-op.
2752
+ return nil
2753
+ }
2754
+
2755
+ func (w *responseWriter) Flush() {
2756
+ w.FlushError()
2757
+ }
2758
+
2759
+ func (w *responseWriter) FlushError() error {
2760
+ rws := w.rws
2761
+ if rws == nil {
2762
+ panic("Header called after Handler finished")
2763
+ }
2764
+ var err error
2765
+ if rws.bw.Buffered() > 0 {
2766
+ err = rws.bw.Flush()
2767
+ } else {
2768
+ // The bufio.Writer won't call chunkWriter.Write
2769
+ // (writeChunk with zero bytes), so we have to do it
2770
+ // ourselves to force the HTTP response header and/or
2771
+ // final DATA frame (with END_STREAM) to be sent.
2772
+ _, err = chunkWriter{rws}.Write(nil)
2773
+ if err == nil {
2774
+ select {
2775
+ case <-rws.stream.cw:
2776
+ err = rws.stream.closeErr
2777
+ default:
2778
+ }
2779
+ }
2780
+ }
2781
+ return err
2782
+ }
2783
+
2784
+ func (w *responseWriter) CloseNotify() <-chan bool {
2785
+ rws := w.rws
2786
+ if rws == nil {
2787
+ panic("CloseNotify called after Handler finished")
2788
+ }
2789
+ rws.closeNotifierMu.Lock()
2790
+ ch := rws.closeNotifierCh
2791
+ if ch == nil {
2792
+ ch = make(chan bool, 1)
2793
+ rws.closeNotifierCh = ch
2794
+ cw := rws.stream.cw
2795
+ go func() {
2796
+ cw.Wait() // wait for close
2797
+ ch <- true
2798
+ }()
2799
+ }
2800
+ rws.closeNotifierMu.Unlock()
2801
+ return ch
2802
+ }
2803
+
2804
+ func (w *responseWriter) Header() http.Header {
2805
+ rws := w.rws
2806
+ if rws == nil {
2807
+ panic("Header called after Handler finished")
2808
+ }
2809
+ if rws.handlerHeader == nil {
2810
+ rws.handlerHeader = make(http.Header)
2811
+ }
2812
+ return rws.handlerHeader
2813
+ }
2814
+
2815
+ // checkWriteHeaderCode is a copy of net/http's checkWriteHeaderCode.
2816
+ func checkWriteHeaderCode(code int) {
2817
+ // Issue 22880: require valid WriteHeader status codes.
2818
+ // For now we only enforce that it's three digits.
2819
+ // In the future we might block things over 599 (600 and above aren't defined
2820
+ // at http://httpwg.org/specs/rfc7231.html#status.codes).
2821
+ // But for now any three digits.
2822
+ //
2823
+ // We used to send "HTTP/1.1 000 0" on the wire in responses but there's
2824
+ // no equivalent bogus thing we can realistically send in HTTP/2,
2825
+ // so we'll consistently panic instead and help people find their bugs
2826
+ // early. (We can't return an error from WriteHeader even if we wanted to.)
2827
+ if code < 100 || code > 999 {
2828
+ panic(fmt.Sprintf("invalid WriteHeader code %v", code))
2829
+ }
2830
+ }
2831
+
2832
+ func (w *responseWriter) WriteHeader(code int) {
2833
+ rws := w.rws
2834
+ if rws == nil {
2835
+ panic("WriteHeader called after Handler finished")
2836
+ }
2837
+ rws.writeHeader(code)
2838
+ }
2839
+
2840
+ func (rws *responseWriterState) writeHeader(code int) {
2841
+ if rws.wroteHeader {
2842
+ return
2843
+ }
2844
+
2845
+ checkWriteHeaderCode(code)
2846
+
2847
+ // Handle informational headers
2848
+ if code >= 100 && code <= 199 {
2849
+ // Per RFC 8297 we must not clear the current header map
2850
+ h := rws.handlerHeader
2851
+
2852
+ _, cl := h["Content-Length"]
2853
+ _, te := h["Transfer-Encoding"]
2854
+ if cl || te {
2855
+ h = h.Clone()
2856
+ h.Del("Content-Length")
2857
+ h.Del("Transfer-Encoding")
2858
+ }
2859
+
2860
+ rws.conn.writeHeaders(rws.stream, &writeResHeaders{
2861
+ streamID: rws.stream.id,
2862
+ httpResCode: code,
2863
+ h: h,
2864
+ endStream: rws.handlerDone && !rws.hasTrailers(),
2865
+ })
2866
+
2867
+ return
2868
+ }
2869
+
2870
+ rws.wroteHeader = true
2871
+ rws.status = code
2872
+ if len(rws.handlerHeader) > 0 {
2873
+ rws.snapHeader = cloneHeader(rws.handlerHeader)
2874
+ }
2875
+ }
2876
+
2877
+ func cloneHeader(h http.Header) http.Header {
2878
+ h2 := make(http.Header, len(h))
2879
+ for k, vv := range h {
2880
+ vv2 := make([]string, len(vv))
2881
+ copy(vv2, vv)
2882
+ h2[k] = vv2
2883
+ }
2884
+ return h2
2885
+ }
2886
+
2887
+ // The Life Of A Write is like this:
2888
+ //
2889
+ // * Handler calls w.Write or w.WriteString ->
2890
+ // * -> rws.bw (*bufio.Writer) ->
2891
+ // * (Handler might call Flush)
2892
+ // * -> chunkWriter{rws}
2893
+ // * -> responseWriterState.writeChunk(p []byte)
2894
+ // * -> responseWriterState.writeChunk (most of the magic; see comment there)
2895
+ func (w *responseWriter) Write(p []byte) (n int, err error) {
2896
+ return w.write(len(p), p, "")
2897
+ }
2898
+
2899
+ func (w *responseWriter) WriteString(s string) (n int, err error) {
2900
+ return w.write(len(s), nil, s)
2901
+ }
2902
+
2903
+ // either dataB or dataS is non-zero.
2904
+ func (w *responseWriter) write(lenData int, dataB []byte, dataS string) (n int, err error) {
2905
+ rws := w.rws
2906
+ if rws == nil {
2907
+ panic("Write called after Handler finished")
2908
+ }
2909
+ if !rws.wroteHeader {
2910
+ w.WriteHeader(200)
2911
+ }
2912
+ if !bodyAllowedForStatus(rws.status) {
2913
+ return 0, http.ErrBodyNotAllowed
2914
+ }
2915
+ rws.wroteBytes += int64(len(dataB)) + int64(len(dataS)) // only one can be set
2916
+ if rws.sentContentLen != 0 && rws.wroteBytes > rws.sentContentLen {
2917
+ // TODO: send a RST_STREAM
2918
+ return 0, errors.New("http2: handler wrote more than declared Content-Length")
2919
+ }
2920
+
2921
+ if dataB != nil {
2922
+ return rws.bw.Write(dataB)
2923
+ } else {
2924
+ return rws.bw.WriteString(dataS)
2925
+ }
2926
+ }
2927
+
2928
+ func (w *responseWriter) handlerDone() {
2929
+ rws := w.rws
2930
+ rws.handlerDone = true
2931
+ w.Flush()
2932
+ w.rws = nil
2933
+ responseWriterStatePool.Put(rws)
2934
+ }
2935
+
2936
+ var _ http.Pusher = (*responseWriter)(nil)
2937
+
2938
+ func (w *responseWriter) Push(target string, opts *http.PushOptions) error {
2939
+ st := w.rws.stream
2940
+ sc := st.sc
2941
+ sc.serveG.checkNotOn()
2942
+
2943
+ // No recursive pushes: "PUSH_PROMISE frames MUST only be sent on a peer-initiated stream."
2944
+ // http://tools.ietf.org/html/rfc7540#section-6.6
2945
+ if st.isPushed() {
2946
+ return ErrRecursivePush
2947
+ }
2948
+
2949
+ if opts == nil {
2950
+ opts = new(http.PushOptions)
2951
+ }
2952
+
2953
+ // Default options.
2954
+ if opts.Method == "" {
2955
+ opts.Method = "GET"
2956
+ }
2957
+ if opts.Header == nil {
2958
+ opts.Header = http.Header{}
2959
+ }
2960
+ wantScheme := "http"
2961
+ if w.rws.req.TLS != nil {
2962
+ wantScheme = "https"
2963
+ }
2964
+
2965
+ // Validate the request.
2966
+ u, err := url.Parse(target)
2967
+ if err != nil {
2968
+ return err
2969
+ }
2970
+ if u.Scheme == "" {
2971
+ if !strings.HasPrefix(target, "/") {
2972
+ return fmt.Errorf("target must be an absolute URL or an absolute path: %q", target)
2973
+ }
2974
+ u.Scheme = wantScheme
2975
+ u.Host = w.rws.req.Host
2976
+ } else {
2977
+ if u.Scheme != wantScheme {
2978
+ return fmt.Errorf("cannot push URL with scheme %q from request with scheme %q", u.Scheme, wantScheme)
2979
+ }
2980
+ if u.Host == "" {
2981
+ return errors.New("URL must have a host")
2982
+ }
2983
+ }
2984
+ for k := range opts.Header {
2985
+ if strings.HasPrefix(k, ":") {
2986
+ return fmt.Errorf("promised request headers cannot include pseudo header %q", k)
2987
+ }
2988
+ // These headers are meaningful only if the request has a body,
2989
+ // but PUSH_PROMISE requests cannot have a body.
2990
+ // http://tools.ietf.org/html/rfc7540#section-8.2
2991
+ // Also disallow Host, since the promised URL must be absolute.
2992
+ if asciiEqualFold(k, "content-length") ||
2993
+ asciiEqualFold(k, "content-encoding") ||
2994
+ asciiEqualFold(k, "trailer") ||
2995
+ asciiEqualFold(k, "te") ||
2996
+ asciiEqualFold(k, "expect") ||
2997
+ asciiEqualFold(k, "host") {
2998
+ return fmt.Errorf("promised request headers cannot include %q", k)
2999
+ }
3000
+ }
3001
+ if err := checkValidHTTP2RequestHeaders(opts.Header); err != nil {
3002
+ return err
3003
+ }
3004
+
3005
+ // The RFC effectively limits promised requests to GET and HEAD:
3006
+ // "Promised requests MUST be cacheable [GET, HEAD, or POST], and MUST be safe [GET or HEAD]"
3007
+ // http://tools.ietf.org/html/rfc7540#section-8.2
3008
+ if opts.Method != "GET" && opts.Method != "HEAD" {
3009
+ return fmt.Errorf("method %q must be GET or HEAD", opts.Method)
3010
+ }
3011
+
3012
+ msg := &startPushRequest{
3013
+ parent: st,
3014
+ method: opts.Method,
3015
+ url: u,
3016
+ header: cloneHeader(opts.Header),
3017
+ done: sc.srv.state.getErrChan(),
3018
+ }
3019
+
3020
+ select {
3021
+ case <-sc.doneServing:
3022
+ return errClientDisconnected
3023
+ case <-st.cw:
3024
+ return errStreamClosed
3025
+ case sc.serveMsgCh <- msg:
3026
+ }
3027
+
3028
+ select {
3029
+ case <-sc.doneServing:
3030
+ return errClientDisconnected
3031
+ case <-st.cw:
3032
+ return errStreamClosed
3033
+ case err := <-msg.done:
3034
+ sc.srv.state.putErrChan(msg.done)
3035
+ return err
3036
+ }
3037
+ }
3038
+
3039
+ type startPushRequest struct {
3040
+ parent *stream
3041
+ method string
3042
+ url *url.URL
3043
+ header http.Header
3044
+ done chan error
3045
+ }
3046
+
3047
+ func (sc *serverConn) startPush(msg *startPushRequest) {
3048
+ sc.serveG.check()
3049
+
3050
+ // http://tools.ietf.org/html/rfc7540#section-6.6.
3051
+ // PUSH_PROMISE frames MUST only be sent on a peer-initiated stream that
3052
+ // is in either the "open" or "half-closed (remote)" state.
3053
+ if msg.parent.state != stateOpen && msg.parent.state != stateHalfClosedRemote {
3054
+ // responseWriter.Push checks that the stream is peer-initiated.
3055
+ msg.done <- errStreamClosed
3056
+ return
3057
+ }
3058
+
3059
+ // http://tools.ietf.org/html/rfc7540#section-6.6.
3060
+ if !sc.pushEnabled {
3061
+ msg.done <- http.ErrNotSupported
3062
+ return
3063
+ }
3064
+
3065
+ // PUSH_PROMISE frames must be sent in increasing order by stream ID, so
3066
+ // we allocate an ID for the promised stream lazily, when the PUSH_PROMISE
3067
+ // is written. Once the ID is allocated, we start the request handler.
3068
+ allocatePromisedID := func() (uint32, error) {
3069
+ sc.serveG.check()
3070
+
3071
+ // Check this again, just in case. Technically, we might have received
3072
+ // an updated SETTINGS by the time we got around to writing this frame.
3073
+ if !sc.pushEnabled {
3074
+ return 0, http.ErrNotSupported
3075
+ }
3076
+ // http://tools.ietf.org/html/rfc7540#section-6.5.2.
3077
+ if sc.curPushedStreams+1 > sc.clientMaxStreams {
3078
+ return 0, ErrPushLimitReached
3079
+ }
3080
+
3081
+ // http://tools.ietf.org/html/rfc7540#section-5.1.1.
3082
+ // Streams initiated by the server MUST use even-numbered identifiers.
3083
+ // A server that is unable to establish a new stream identifier can send a GOAWAY
3084
+ // frame so that the client is forced to open a new connection for new streams.
3085
+ if sc.maxPushPromiseID+2 >= 1<<31 {
3086
+ sc.startGracefulShutdownInternal()
3087
+ return 0, ErrPushLimitReached
3088
+ }
3089
+ sc.maxPushPromiseID += 2
3090
+ promisedID := sc.maxPushPromiseID
3091
+
3092
+ // http://tools.ietf.org/html/rfc7540#section-8.2.
3093
+ // Strictly speaking, the new stream should start in "reserved (local)", then
3094
+ // transition to "half closed (remote)" after sending the initial HEADERS, but
3095
+ // we start in "half closed (remote)" for simplicity.
3096
+ // See further comments at the definition of stateHalfClosedRemote.
3097
+ promised := sc.newStream(promisedID, msg.parent.id, stateHalfClosedRemote, defaultRFC9218Priority(sc.priorityAware && !sc.hasIntermediary))
3098
+ rw, req, err := sc.newWriterAndRequestNoBody(promised, httpcommon.ServerRequestParam{
3099
+ Method: msg.method,
3100
+ Scheme: msg.url.Scheme,
3101
+ Authority: msg.url.Host,
3102
+ Path: msg.url.RequestURI(),
3103
+ Header: cloneHeader(msg.header), // clone since handler runs concurrently with writing the PUSH_PROMISE
3104
+ })
3105
+ if err != nil {
3106
+ // Should not happen, since we've already validated msg.url.
3107
+ panic(fmt.Sprintf("newWriterAndRequestNoBody(%+v): %v", msg.url, err))
3108
+ }
3109
+
3110
+ sc.curHandlers++
3111
+ go sc.runHandler(rw, req, sc.handler.ServeHTTP)
3112
+ return promisedID, nil
3113
+ }
3114
+
3115
+ sc.writeFrame(FrameWriteRequest{
3116
+ write: &writePushPromise{
3117
+ streamID: msg.parent.id,
3118
+ method: msg.method,
3119
+ url: msg.url,
3120
+ h: msg.header,
3121
+ allocatePromisedID: allocatePromisedID,
3122
+ },
3123
+ stream: msg.parent,
3124
+ done: msg.done,
3125
+ })
3126
+ }
3127
+
3128
+ // foreachHeaderElement splits v according to the "#rule" construction
3129
+ // in RFC 7230 section 7 and calls fn for each non-empty element.
3130
+ func foreachHeaderElement(v string, fn func(string)) {
3131
+ v = textproto.TrimString(v)
3132
+ if v == "" {
3133
+ return
3134
+ }
3135
+ if !strings.Contains(v, ",") {
3136
+ fn(v)
3137
+ return
3138
+ }
3139
+ for _, f := range strings.Split(v, ",") {
3140
+ if f = textproto.TrimString(f); f != "" {
3141
+ fn(f)
3142
+ }
3143
+ }
3144
+ }
3145
+
3146
+ // From http://httpwg.org/specs/rfc7540.html#rfc.section.8.1.2.2
3147
+ var connHeaders = []string{
3148
+ "Connection",
3149
+ "Keep-Alive",
3150
+ "Proxy-Connection",
3151
+ "Transfer-Encoding",
3152
+ "Upgrade",
3153
+ }
3154
+
3155
+ // checkValidHTTP2RequestHeaders checks whether h is a valid HTTP/2 request,
3156
+ // per RFC 7540 Section 8.1.2.2.
3157
+ // The returned error is reported to users.
3158
+ func checkValidHTTP2RequestHeaders(h http.Header) error {
3159
+ for _, k := range connHeaders {
3160
+ if _, ok := h[k]; ok {
3161
+ return fmt.Errorf("request header %q is not valid in HTTP/2", k)
3162
+ }
3163
+ }
3164
+ te := h["Te"]
3165
+ if len(te) > 0 && (len(te) > 1 || (te[0] != "trailers" && te[0] != "")) {
3166
+ return errors.New(`request header "TE" may only be "trailers" in HTTP/2`)
3167
+ }
3168
+ return nil
3169
+ }
3170
+
3171
+ func new400Handler(err error) http.HandlerFunc {
3172
+ return func(w http.ResponseWriter, r *http.Request) {
3173
+ http.Error(w, err.Error(), http.StatusBadRequest)
3174
+ }
3175
+ }
3176
+
3177
+ // h1ServerKeepAlivesDisabled reports whether hs has its keep-alives
3178
+ // disabled. See comments on h1ServerShutdownChan above for why
3179
+ // the code is written this way.
3180
+ func h1ServerKeepAlivesDisabled(hs *http.Server) bool {
3181
+ var x interface{} = hs
3182
+ type I interface {
3183
+ doKeepAlives() bool
3184
+ }
3185
+ if hs, ok := x.(I); ok {
3186
+ return !hs.doKeepAlives()
3187
+ }
3188
+ return false
3189
+ }
3190
+
3191
+ func (sc *serverConn) countError(name string, err error) error {
3192
+ if sc == nil || sc.srv == nil {
3193
+ return err
3194
+ }
3195
+ f := sc.countErrorFunc
3196
+ if f == nil {
3197
+ return err
3198
+ }
3199
+ var typ string
3200
+ var code ErrCode
3201
+ switch e := err.(type) {
3202
+ case ConnectionError:
3203
+ typ = "conn"
3204
+ code = ErrCode(e)
3205
+ case StreamError:
3206
+ typ = "stream"
3207
+ code = ErrCode(e.Code)
3208
+ default:
3209
+ return err
3210
+ }
3211
+ codeStr := errCodeName[code]
3212
+ if codeStr == "" {
3213
+ codeStr = strconv.Itoa(int(code))
3214
+ }
3215
+ f(fmt.Sprintf("%s_%s_%s", typ, codeStr, name))
3216
+ return err
3217
+ }