e621stream 0.0.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 (77) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +35 -0
  4. data/lib/e621stream/client/options.rb +20 -0
  5. data/lib/e621stream/client.rb +211 -0
  6. data/lib/e621stream/close_codes.rb +23 -0
  7. data/lib/e621stream/event.rb +24 -0
  8. data/lib/e621stream/events.rb +29 -0
  9. data/lib/e621stream/stream_error.rb +18 -0
  10. data/lib/e621stream/version.rb +5 -0
  11. data/lib/e621stream.rb +18 -0
  12. data/sorbet/config +6 -0
  13. data/sorbet/rbi/annotations/.gitattributes +1 -0
  14. data/sorbet/rbi/annotations/minitest.rbi +120 -0
  15. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  16. data/sorbet/rbi/gems/.gitattributes +1 -0
  17. data/sorbet/rbi/gems/ast@2.4.3.rbi +550 -0
  18. data/sorbet/rbi/gems/async-http@0.105.0.rbi +1649 -0
  19. data/sorbet/rbi/gems/async-pool@0.12.0.rbi +219 -0
  20. data/sorbet/rbi/gems/async-websocket@0.30.2.rbi +271 -0
  21. data/sorbet/rbi/gems/async@2.46.0.rbi +2193 -0
  22. data/sorbet/rbi/gems/benchmark@0.5.0.rbi +495 -0
  23. data/sorbet/rbi/gems/console@1.38.0.rbi +1552 -0
  24. data/sorbet/rbi/gems/erb@6.0.7.rbi +1581 -0
  25. data/sorbet/rbi/gems/erubi@1.13.1.rbi +153 -0
  26. data/sorbet/rbi/gems/fiber-annotation@0.2.0.rbi +62 -0
  27. data/sorbet/rbi/gems/fiber-local@1.1.0.rbi +36 -0
  28. data/sorbet/rbi/gems/fiber-storage@1.0.1.rbi +43 -0
  29. data/sorbet/rbi/gems/io-console@0.9.5.rbi +9 -0
  30. data/sorbet/rbi/gems/io-endpoint@0.19.0.rbi +1079 -0
  31. data/sorbet/rbi/gems/io-event@1.22.3.rbi +971 -0
  32. data/sorbet/rbi/gems/io-stream@0.14.0.rbi +805 -0
  33. data/sorbet/rbi/gems/json@3.1.0.rbi +1929 -0
  34. data/sorbet/rbi/gems/language_server-protocol@3.17.0.6.rbi +9 -0
  35. data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +189 -0
  36. data/sorbet/rbi/gems/logger@1.7.0.rbi +896 -0
  37. data/sorbet/rbi/gems/minitest@5.27.0.rbi +1499 -0
  38. data/sorbet/rbi/gems/netrc@0.11.0.rbi +147 -0
  39. data/sorbet/rbi/gems/openssl@4.0.2.rbi +4366 -0
  40. data/sorbet/rbi/gems/parallel@2.3.0.rbi +332 -0
  41. data/sorbet/rbi/gems/parser@3.3.13.0.rbi +5146 -0
  42. data/sorbet/rbi/gems/pp@0.6.4.rbi +373 -0
  43. data/sorbet/rbi/gems/prettyprint@0.2.1.rbi +476 -0
  44. data/sorbet/rbi/gems/prism@1.9.0.rbi +42213 -0
  45. data/sorbet/rbi/gems/protocol-hpack@1.5.1.rbi +418 -0
  46. data/sorbet/rbi/gems/protocol-http1@0.41.1.rbi +894 -0
  47. data/sorbet/rbi/gems/protocol-http2@0.29.2.rbi +2277 -0
  48. data/sorbet/rbi/gems/protocol-http@0.72.1.rbi +3801 -0
  49. data/sorbet/rbi/gems/protocol-rack@0.23.0.rbi +9 -0
  50. data/sorbet/rbi/gems/protocol-url@0.19.0.rbi +9 -0
  51. data/sorbet/rbi/gems/protocol-websocket@0.21.3.rbi +1087 -0
  52. data/sorbet/rbi/gems/racc@1.8.1.rbi +169 -0
  53. data/sorbet/rbi/gems/rack@3.2.8.rbi +9 -0
  54. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +362 -0
  55. data/sorbet/rbi/gems/rake@13.4.2.rbi +3127 -0
  56. data/sorbet/rbi/gems/rbi@0.5.0.rbi +5875 -0
  57. data/sorbet/rbi/gems/rbs@4.2.0.rbi +7133 -0
  58. data/sorbet/rbi/gems/rdoc@8.1.0.rbi +9 -0
  59. data/sorbet/rbi/gems/regexp_parser@2.13.1.rbi +3500 -0
  60. data/sorbet/rbi/gems/reline@0.7.0.rbi +2449 -0
  61. data/sorbet/rbi/gems/require-hooks@0.5.1.rbi +152 -0
  62. data/sorbet/rbi/gems/rexml@3.4.4.rbi +4905 -0
  63. data/sorbet/rbi/gems/rubocop-ast@1.51.0.rbi +7230 -0
  64. data/sorbet/rbi/gems/rubocop-rake@0.7.1.rbi +314 -0
  65. data/sorbet/rbi/gems/rubocop@1.92.2.rbi +69094 -0
  66. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +988 -0
  67. data/sorbet/rbi/gems/rubydex@0.4.4.rbi +1620 -0
  68. data/sorbet/rbi/gems/spoom@1.8.13.rbi +7380 -0
  69. data/sorbet/rbi/gems/tapioca@0.20.0.rbi +3752 -0
  70. data/sorbet/rbi/gems/thor@1.5.0.rbi +3870 -0
  71. data/sorbet/rbi/gems/tsort@0.2.0.rbi +389 -0
  72. data/sorbet/rbi/gems/unicode-display_width@3.3.0.rbi +130 -0
  73. data/sorbet/rbi/gems/unicode-emoji@4.3.0.rbi +254 -0
  74. data/sorbet/rbi/gems/zeitwerk@2.8.3.rbi +1178 -0
  75. data/sorbet/tapioca/config.yml +13 -0
  76. data/sorbet/tapioca/require.rb +4 -0
  77. metadata +175 -0
@@ -0,0 +1,3801 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `protocol-http` gem.
5
+ # Please instead update this file by running `bin/tapioca gem protocol-http`.
6
+
7
+
8
+ # @namespace
9
+ # Released under the MIT License.
10
+ # Copyright, 2019-2024, by Samuel Williams.
11
+ # Copyright, 2022, by Dan Olson.
12
+ # Released under the MIT License.
13
+ # Copyright, 2019-2026, by Samuel Williams.
14
+ # Copyright, 2023, by Genki Takiuchi.
15
+ # Copyright, 2025, by William T. Nelson.
16
+ # Released under the MIT License.
17
+ # Copyright, 2018-2026, by Samuel Williams.
18
+ # Released under the MIT License.
19
+ # Copyright, 2019-2025, by Samuel Williams.
20
+ # Copyright, 2024, by Earlopain.
21
+ # Released under the MIT License.
22
+ # Copyright, 2020-2025, by Samuel Williams.
23
+ # Released under the MIT License.
24
+ # Copyright, 2019-2025, by Samuel Williams.
25
+ # Released under the MIT License.
26
+ # Copyright, 2019-2026, by Samuel Williams.
27
+ # Released under the MIT License.
28
+ # Copyright, 2024-2025, by Samuel Williams.
29
+ # Released under the MIT License.
30
+ # Copyright, 2025-2026, by Samuel Williams.
31
+ # Released under the MIT License.
32
+ # Copyright, 2026, by Samuel Williams.
33
+ #
34
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:8
35
+ module Protocol; end
36
+
37
+ # @namespace
38
+ #
39
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:9
40
+ module Protocol::HTTP; end
41
+
42
+ # Marks errors which may indicate a malformed or invalid request when raised while processing an incoming request.
43
+ #
44
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:26
45
+ module Protocol::HTTP::BadRequest; end
46
+
47
+ # @namespace
48
+ #
49
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:10
50
+ module Protocol::HTTP::Body; end
51
+
52
+ # A body which buffers all its contents.
53
+ #
54
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:14
55
+ class Protocol::HTTP::Body::Buffered < ::Protocol::HTTP::Body::Readable
56
+ # Initialize the buffered body with some chunks.
57
+ #
58
+ # @parameter chunks [Array(String)] the chunks to buffer.
59
+ # @parameter length [Integer] the length of the body, if known.
60
+ #
61
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:51
62
+ def initialize(chunks = T.unsafe(nil), length = T.unsafe(nil)); end
63
+
64
+ # A rewindable body wraps some other body. Convert it to a buffered body. The buffered body will share the same chunks as the rewindable body.
65
+ #
66
+ # @returns [Buffered] the buffered body.
67
+ #
68
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:64
69
+ def buffered; end
70
+
71
+ # @attribute [Array(String)] chunks the buffered chunks.
72
+ #
73
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:59
74
+ def chunks; end
75
+
76
+ # Clear the buffered chunks.
77
+ #
78
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:85
79
+ def clear; end
80
+
81
+ # Ensure that future reads return `nil`, but allow for rewinding.
82
+ #
83
+ # @parameter error [Exception | Nil] the error that caused the body to be closed, if any.
84
+ #
85
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:78
86
+ def close(error = T.unsafe(nil)); end
87
+
88
+ # Close the body for writing. This is a no-op.
89
+ #
90
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:132
91
+ def close_write(error); end
92
+
93
+ # Discard the body. Invokes {#close}.
94
+ #
95
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:121
96
+ def discard; end
97
+
98
+ # @returns [Boolean] if the body is empty.
99
+ #
100
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:97
101
+ def empty?; end
102
+
103
+ # Finish the body, this is a no-op.
104
+ #
105
+ # @returns [Buffered] self.
106
+ #
107
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:71
108
+ def finish; end
109
+
110
+ # Inspect the buffered body.
111
+ #
112
+ # @returns [String] a string representation of the buffered body.
113
+ #
114
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:155
115
+ def inspect; end
116
+
117
+ # The length of the body. Will compute and cache the length of the body, if it was not provided.
118
+ #
119
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:92
120
+ def length; end
121
+
122
+ # Read the next chunk from the buffered body.
123
+ #
124
+ # @returns [String | Nil] the next chunk or nil if there are no more chunks.
125
+ #
126
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:110
127
+ def read; end
128
+
129
+ # Whether the body is ready to be read.
130
+ # @returns [Boolean] a buffered response is always ready.
131
+ #
132
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:103
133
+ def ready?; end
134
+
135
+ # Rewind the body to the beginning, causing a subsequent read to return the first chunk.
136
+ #
137
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:144
138
+ def rewind; end
139
+
140
+ # Whether the body can be rewound.
141
+ #
142
+ # @returns [Boolean] if the body has chunks.
143
+ #
144
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:139
145
+ def rewindable?; end
146
+
147
+ # Write a chunk to the buffered body.
148
+ #
149
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:127
150
+ def write(chunk); end
151
+
152
+ class << self
153
+ # Read the entire body into a buffered representation.
154
+ #
155
+ # @parameter body [Readable] the body to read.
156
+ # @returns [Buffered] the buffered body.
157
+ #
158
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:37
159
+ def read(body); end
160
+
161
+ # Tries to wrap an object in a {Buffered} instance.
162
+ #
163
+ # For compatibility, also accepts anything that behaves like an `Array(String)`.
164
+ #
165
+ # @parameter body [String | Array(String) | Readable | nil] the body to wrap.
166
+ # @returns [Readable | nil] the wrapped body or nil if nil was given.
167
+ #
168
+ # pkg:gem/protocol-http#lib/protocol/http/body/buffered.rb:21
169
+ def wrap(object); end
170
+ end
171
+ end
172
+
173
+ # Invokes a callback once the body has completed, either successfully or due to an error.
174
+ #
175
+ # pkg:gem/protocol-http#lib/protocol/http/body/completable.rb:12
176
+ class Protocol::HTTP::Body::Completable < ::Protocol::HTTP::Body::Wrapper
177
+ # Initialize the completable body with a callback.
178
+ #
179
+ # @parameter body [Readable] the body to wrap.
180
+ # @parameter callback [Proc] the callback to invoke when the body is closed.
181
+ #
182
+ # pkg:gem/protocol-http#lib/protocol/http/body/completable.rb:29
183
+ def initialize(body, callback); end
184
+
185
+ # Convert the body to a hash suitable for serialization.
186
+ #
187
+ # @returns [Hash] The body as a hash.
188
+ #
189
+ # pkg:gem/protocol-http#lib/protocol/http/body/completable.rb:60
190
+ def as_json(*, **, &); end
191
+
192
+ # Close the body and invoke the callback. If an error is given, it is passed to the callback.
193
+ #
194
+ # The calback is only invoked once, and before `super` is invoked.
195
+ #
196
+ # pkg:gem/protocol-http#lib/protocol/http/body/completable.rb:48
197
+ def close(error = T.unsafe(nil)); end
198
+
199
+ # Inspect the completable body.
200
+ #
201
+ # @returns [String] a string representation of the completable body.
202
+ #
203
+ # pkg:gem/protocol-http#lib/protocol/http/body/completable.rb:69
204
+ def inspect; end
205
+
206
+ # Rewind the body, is not supported.
207
+ #
208
+ # pkg:gem/protocol-http#lib/protocol/http/body/completable.rb:41
209
+ def rewind; end
210
+
211
+ # @returns [Boolean] completable bodies are not rewindable.
212
+ #
213
+ # pkg:gem/protocol-http#lib/protocol/http/body/completable.rb:36
214
+ def rewindable?; end
215
+
216
+ class << self
217
+ # Wrap a message body with a callback. If the body is empty, the callback is invoked immediately.
218
+ #
219
+ # @parameter message [Request | Response] the message body.
220
+ # @parameter block [Proc] the callback to invoke when the body is closed.
221
+ #
222
+ # pkg:gem/protocol-http#lib/protocol/http/body/completable.rb:17
223
+ def wrap(message, &block); end
224
+ end
225
+ end
226
+
227
+ # Represents a body suitable for HEAD requests, in other words, a body that is empty and has a known length.
228
+ #
229
+ # pkg:gem/protocol-http#lib/protocol/http/body/head.rb:13
230
+ class Protocol::HTTP::Body::Head < ::Protocol::HTTP::Body::Readable
231
+ # Initialize the head body with the given length.
232
+ #
233
+ # @parameter length [Integer] the length of the body.
234
+ #
235
+ # pkg:gem/protocol-http#lib/protocol/http/body/head.rb:38
236
+ def initialize(length); end
237
+
238
+ # @returns [Boolean] the body is empty.
239
+ #
240
+ # pkg:gem/protocol-http#lib/protocol/http/body/head.rb:43
241
+ def empty?; end
242
+
243
+ # Inspect the head body.
244
+ #
245
+ # @returns [String] a string representation of the head body.
246
+ #
247
+ # pkg:gem/protocol-http#lib/protocol/http/body/head.rb:60
248
+ def inspect; end
249
+
250
+ # @returns [Integer] the length of the body, if known.
251
+ #
252
+ # pkg:gem/protocol-http#lib/protocol/http/body/head.rb:53
253
+ def length; end
254
+
255
+ # @returns [Boolean] the body is ready.
256
+ #
257
+ # pkg:gem/protocol-http#lib/protocol/http/body/head.rb:48
258
+ def ready?; end
259
+
260
+ class << self
261
+ # Create a head body for the given body, capturing its length and then closing it.
262
+ #
263
+ # If a body is provided, the length is determined from the body, and the body is closed.
264
+ # If no body is provided, and the content length is provided, a head body is created with that length.
265
+ # This is useful for creating a head body when you only know the content length but not the actual body, which may happen in adapters for HTTP applications where the application may not provide a body for HEAD requests, but the content length is known.
266
+ #
267
+ # @parameter body [Readable | Nil] the body to create a head for.
268
+ # @parameter length [Integer | Nil] the content length of the body, if known.
269
+ # @returns [Head | Nil] the head body, or nil if the body is nil.
270
+ #
271
+ # pkg:gem/protocol-http#lib/protocol/http/body/head.rb:23
272
+ def for(body, length = T.unsafe(nil)); end
273
+ end
274
+ end
275
+
276
+ # Represents a readable input streams.
277
+ #
278
+ # There are two major modes of operation:
279
+ #
280
+ # 1. Reading chunks using {read} (or {each}/{join}), until the body is empty, or
281
+ # 2. Streaming chunks using {call}, which writes chunks to a provided output stream.
282
+ #
283
+ # In both cases, reading can fail, for example if the body represents a streaming upload, and the connection is lost. In this case, {read} will raise some kind of error, or the stream will be closed with an error.
284
+ #
285
+ # At any point, you can use {close} to close the stream and release any resources, or {discard} to read all remaining data without processing it which may allow the underlying connection to be reused (but can be slower).
286
+ #
287
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:22
288
+ class Protocol::HTTP::Body::Readable
289
+ # Convert the body to a hash suitable for serialization. This won't include the contents of the body, but will include metadata such as the length, streamability, and readiness, etc.
290
+ #
291
+ # @returns [Hash] The body as a hash.
292
+ #
293
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:179
294
+ def as_json(*, **, &); end
295
+
296
+ # Return a buffered representation of this body.
297
+ #
298
+ # This method must return a buffered body if `#rewindable?`.
299
+ #
300
+ # @returns [Buffered | Nil] The buffered body.
301
+ #
302
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:73
303
+ def buffered; end
304
+
305
+ # Invoke the body with the given stream.
306
+ #
307
+ # The default implementation simply writes each chunk to the stream. If the body is not ready, it will be flushed after each chunk. Closes the stream when finished or if an error occurs.
308
+ #
309
+ # Write the body to the given stream.
310
+ #
311
+ # @parameter stream [IO | Object] An `IO`-like object that responds to `#read`, `#write` and `#flush`.
312
+ # @returns [Boolean] Whether the ownership of the stream was transferred.
313
+ #
314
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:144
315
+ def call(stream); end
316
+
317
+ # Close the stream immediately. After invoking this method, the stream should be considered closed, and all internal resources should be released.
318
+ #
319
+ # Closing the stream before it reaches end-of-file abandons any remaining input. The protocol implementation must account for that unread data before the associated exchange or connection can be reused. Depending on the protocol, it may discard the remaining data, terminate the exchange, or make the connection non-reusable. Use {discard} when preserving the exchange or connection is preferred.
320
+ #
321
+ # When closing before end-of-file, omitting the error represents deliberate application-level abandonment, not a protocol failure.
322
+ #
323
+ # If an error occurred while handling the output, it can be passed as an argument. This may be propagated to the client, for example the client may be informed that the stream was not fully read correctly.
324
+ #
325
+ # Invoking {read} after {close} will return `nil`.
326
+ #
327
+ # @parameter error [Exception | Nil] The error that caused this stream to be closed, if any.
328
+ #
329
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:34
330
+ def close(error = T.unsafe(nil)); end
331
+
332
+ # Discard the body as efficiently as possible.
333
+ #
334
+ # The default implementation simply reads all chunks until the body is empty.
335
+ #
336
+ # Useful for discarding the body when it is not needed, but preserving the underlying connection.
337
+ #
338
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:171
339
+ def discard; end
340
+
341
+ # Enumerate all chunks until finished, then invoke {close}.
342
+ #
343
+ # Closes the stream when finished or if an error occurs.
344
+ #
345
+ # @yields {|chunk| ...} The block to call with each chunk of data.
346
+ # @parameter chunk [String | Nil] The chunk of data, or `nil` if the stream has finished.
347
+ #
348
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:98
349
+ def each; end
350
+
351
+ # Optimistically determine whether read (may) return any data.
352
+ #
353
+ # - If this returns true, then calling read will definitely return nil.
354
+ # - If this returns false, then calling read may return nil.
355
+ #
356
+ # @return [Boolean] Whether the stream is empty.
357
+ #
358
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:43
359
+ def empty?; end
360
+
361
+ # Read all remaining chunks into a buffered body and close the underlying input.
362
+ #
363
+ # @returns [Buffered] The buffered body.
364
+ #
365
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:161
366
+ def finish; end
367
+
368
+ # Read all remaining chunks into a single binary string using `#each`.
369
+ #
370
+ # @returns [String | Nil] The binary string containing all chunks of data, or `nil` if the stream has finished (or did not contain any data).
371
+ #
372
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:115
373
+ def join; end
374
+
375
+ # The total length of the body, if known.
376
+ #
377
+ # @returns [Integer | Nil] The total length of the body, or `nil` if the length is unknown.
378
+ #
379
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:80
380
+ def length; end
381
+
382
+ # Read the next available chunk.
383
+ #
384
+ # @returns [String | Nil] The chunk of data, or `nil` if the stream has finished.
385
+ # @raises [StandardError] If an error occurs while reading.
386
+ #
387
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:88
388
+ def read; end
389
+
390
+ # Whether calling read will return a chunk of data without blocking. We prefer pessimistic implementation, and thus default to `false`.
391
+ #
392
+ # @return [Boolean] Whether the stream is ready (read will not block).
393
+ #
394
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:50
395
+ def ready?; end
396
+
397
+ # Rewind the stream to the beginning.
398
+ #
399
+ # @returns [Boolean] Whether the stream was successfully rewound.
400
+ #
401
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:64
402
+ def rewind; end
403
+
404
+ # Whether the stream can be rewound using {rewind}.
405
+ #
406
+ # @return [Boolean] Whether the stream is rewindable.
407
+ #
408
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:57
409
+ def rewindable?; end
410
+
411
+ # Whether to prefer streaming the body using {call} rather than reading it using {read} or {each}.
412
+ #
413
+ # @returns [Boolean] Whether the body should be streamed.
414
+ #
415
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:132
416
+ def stream?; end
417
+
418
+ # Return an IO-compatible stream for reading this body.
419
+ # @returns [Stream] The IO-compatible stream adapter.
420
+ #
421
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:198
422
+ def to_io; end
423
+
424
+ # Convert the body to JSON.
425
+ #
426
+ # @returns [String] The body as JSON.
427
+ #
428
+ # pkg:gem/protocol-http#lib/protocol/http/body/readable.rb:192
429
+ def to_json(*, **, &); end
430
+ end
431
+
432
+ # General operations for interacting with a request or response body.
433
+ #
434
+ # This module is included in both {Request} and {Response}.
435
+ #
436
+ # pkg:gem/protocol-http#lib/protocol/http/body/reader.rb:13
437
+ module Protocol::HTTP::Body::Reader
438
+ # Whether there is a body?
439
+ #
440
+ # @returns [Boolean] whether there is a body.
441
+ #
442
+ # pkg:gem/protocol-http#lib/protocol/http/body/reader.rb:98
443
+ def body?; end
444
+
445
+ # Buffer the entire request/response body.
446
+ #
447
+ # @returns [Reader] itself.
448
+ #
449
+ # pkg:gem/protocol-http#lib/protocol/http/body/reader.rb:61
450
+ def buffered!; end
451
+
452
+ # Close the connection as quickly as possible. Discards body. May close the underlying connection if necessary to terminate the stream.
453
+ #
454
+ # @parameter error [Exception | Nil] the error that caused the stream to be closed, if any.
455
+ #
456
+ # pkg:gem/protocol-http#lib/protocol/http/body/reader.rb:88
457
+ def close(error = T.unsafe(nil)); end
458
+
459
+ # Discard the body as efficiently as possible.
460
+ #
461
+ # pkg:gem/protocol-http#lib/protocol/http/body/reader.rb:49
462
+ def discard; end
463
+
464
+ # Read chunks from the body.
465
+ #
466
+ # @yields {|chunk| ...} chunks from the body.
467
+ #
468
+ # pkg:gem/protocol-http#lib/protocol/http/body/reader.rb:17
469
+ def each(&block); end
470
+
471
+ # Gracefully finish reading the body. This will buffer the remainder of the body.
472
+ #
473
+ # @returns [Buffered] buffers the entire body.
474
+ #
475
+ # pkg:gem/protocol-http#lib/protocol/http/body/reader.rb:39
476
+ def finish; end
477
+
478
+ # Reads the entire request/response body.
479
+ #
480
+ # @returns [String] the entire body as a string.
481
+ #
482
+ # pkg:gem/protocol-http#lib/protocol/http/body/reader.rb:27
483
+ def read; end
484
+
485
+ # Write the body of the response to the given file path.
486
+ #
487
+ # @parameter path [String] the path to write the body to.
488
+ # @parameter mode [Integer] the mode to open the file with.
489
+ # @parameter options [Hash] additional options to pass to `File.open`.
490
+ #
491
+ # pkg:gem/protocol-http#lib/protocol/http/body/reader.rb:75
492
+ def save(path, mode = T.unsafe(nil), **options); end
493
+ end
494
+
495
+ # The input stream is an IO-like object which contains the raw HTTP POST data. When applicable, its external encoding must be "ASCII-8BIT" and it must be opened in binary mode, for Ruby 1.9 compatibility. The input stream must respond to gets, each, read and rewind.
496
+ #
497
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:12
498
+ class Protocol::HTTP::Body::Stream
499
+ include ::Protocol::HTTP::Body::Stream::Reader
500
+
501
+ # Initialize the stream with the given input and output.
502
+ #
503
+ # @parameter input [Readable | Nil] The input stream.
504
+ # @parameter output [Writable | Nil] The output stream.
505
+ #
506
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:20
507
+ def initialize(input = T.unsafe(nil), output = T.unsafe(nil)); end
508
+
509
+ # Write data to the stream using {write}.
510
+ #
511
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:324
512
+ def <<(buffer); end
513
+
514
+ # Close the input and output bodies.
515
+ #
516
+ # Closing without an error represents orderly completion or abandonment of both application-facing directions, not cancellation. If the peer has not completed the exchange, the protocol implementation may need to terminate it without reporting an application error.
517
+ #
518
+ # Repeated calls are safe; each underlying direction will be closed at most once.
519
+ #
520
+ # @parameter error [Exception | Nil] The error that caused this stream to be closed, if any.
521
+ #
522
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:395
523
+ def close(error = T.unsafe(nil)); end
524
+
525
+ # Close the application-facing input body. This does not close the output body, which may continue to be written independently.
526
+ #
527
+ # If the input has not reached end-of-file, any remaining data is abandoned. The protocol implementation must ensure that unread data cannot interfere with subsequent exchanges. Depending on the protocol, it may discard the remaining data, terminate the current exchange, or make the connection non-reusable.
528
+ #
529
+ # Closing without an error represents orderly application-level abandonment, not a protocol failure.
530
+ #
531
+ # This method is idempotent. After the first call, subsequent calls have no effect.
532
+ #
533
+ # If, while processing the data that was read from this stream, an error is encountered, it should be passed to this method.
534
+ #
535
+ # @parameter error [Exception | Nil] The error that was encountered, if any.
536
+ #
537
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:361
538
+ def close_read(error = T.unsafe(nil)); end
539
+
540
+ # Close the application-facing output body. This does not close the input body, which may continue to be read independently.
541
+ #
542
+ # Closing without an error indicates that no more output will be produced. Previously written data remains part of the output and should be followed by a normal end-of-stream from the protocol implementation. If an error is provided, the protocol implementation may terminate the exchange instead.
543
+ #
544
+ # This method is idempotent. After the first call, subsequent calls have no effect.
545
+ #
546
+ # If, while generating the data that is written to this stream, an error is encountered, it should be passed to this method.
547
+ #
548
+ # @parameter error [Exception | Nil] The error that was encountered, if any.
549
+ #
550
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:380
551
+ def close_write(error = T.unsafe(nil)); end
552
+
553
+ # @returns [Boolean] Whether the stream has been closed.
554
+ #
555
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:405
556
+ def closed?; end
557
+
558
+ # @returns [Boolean] Whether there are any output chunks remaining.
559
+ #
560
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:425
561
+ def empty?; end
562
+
563
+ # Flush the output stream.
564
+ #
565
+ # This is currently a no-op.
566
+ #
567
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:347
568
+ def flush; end
569
+
570
+ # @attribute [Readable | Nil] The input stream.
571
+ #
572
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:36
573
+ def input; end
574
+
575
+ # Inspect the stream.
576
+ #
577
+ # @returns [String] a string representation of the stream.
578
+ #
579
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:412
580
+ def inspect; end
581
+
582
+ # @attribute [Writable | Nil] The output stream.
583
+ #
584
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:39
585
+ def output; end
586
+
587
+ # Write lines to the stream.
588
+ #
589
+ # The current implementation buffers the lines and writes them in a single operation.
590
+ #
591
+ # @parameter arguments [Array(String)] The lines to write.
592
+ # @parameter separator [String] The line separator, defaults to `\n`.
593
+ #
594
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:334
595
+ def puts(*arguments, separator: T.unsafe(nil)); end
596
+
597
+ # Write data to the underlying stream.
598
+ #
599
+ # @parameter buffer [String] The data to write.
600
+ # @raises [IOError] If the stream is not writable.
601
+ # @returns [Integer] The number of bytes written.
602
+ #
603
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:303
604
+ def write(buffer); end
605
+
606
+ # Write data to the stream using {write}.
607
+ #
608
+ # Provided for compatibility with IO-like objects.
609
+ #
610
+ # @parameter buffer [String] The data to write.
611
+ # @parameter exception [Boolean] Whether to raise an exception if the write would block, currently ignored.
612
+ # @returns [Integer] The number of bytes written.
613
+ #
614
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:319
615
+ def write_nonblock(buffer, exception: T.unsafe(nil)); end
616
+
617
+ private
618
+
619
+ # Read the next chunk of data from the input stream.
620
+ #
621
+ # @returns [String] The next chunk of data.
622
+ # @raises [IOError] If the input stream was explicitly closed.
623
+ #
624
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:439
625
+ def read_next; end
626
+ end
627
+
628
+ # The default line separator, used by {gets}.
629
+ #
630
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:14
631
+ Protocol::HTTP::Body::Stream::NEWLINE = T.let(T.unsafe(nil), String)
632
+
633
+ # This provides a read-only interface for data, which is surprisingly tricky to implement correctly.
634
+ #
635
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:42
636
+ module Protocol::HTTP::Body::Stream::Reader
637
+ # Iterate over each chunk of data from the input stream.
638
+ #
639
+ # @yields {|chunk| ...} Each chunk of data.
640
+ #
641
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:149
642
+ def each(&block); end
643
+
644
+ # Read a single line from the stream.
645
+ #
646
+ # @parameter separator [String] The line separator, defaults to `\n`.
647
+ # @parameter limit [Integer] The maximum number of bytes to read.
648
+ # @parameter *options [Hash] Additional options, passed to {read_until}.
649
+ #
650
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:232
651
+ def gets(separator = T.unsafe(nil), limit = T.unsafe(nil), chomp: T.unsafe(nil)); end
652
+
653
+ # Read data from the underlying stream.
654
+ #
655
+ # If given a non-negative length, it will read at most that many bytes from the stream. If the stream is at EOF, it will return nil.
656
+ #
657
+ # If the length is not given, it will read all data until EOF, or return an empty string if the stream is already at EOF.
658
+ #
659
+ # If buffer is given, then the read data will be placed into buffer instead of a newly created String object.
660
+ #
661
+ # @parameter length [Integer] the amount of data to read
662
+ # @parameter buffer [String] the buffer which will receive the data
663
+ # @returns [String] a buffer containing the data
664
+ #
665
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:54
666
+ def read(length = T.unsafe(nil), buffer = T.unsafe(nil)); end
667
+
668
+ # Read data from the stream without blocking if possible.
669
+ #
670
+ # @parameter length [Integer] The maximum number of bytes to read.
671
+ # @parameter buffer [String | Nil] The buffer to read into.
672
+ #
673
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:166
674
+ def read_nonblock(length, buffer = T.unsafe(nil), exception: T.unsafe(nil)); end
675
+
676
+ # Read some bytes from the stream.
677
+ #
678
+ # If the length is given, at most length bytes will be read. Otherwise, one chunk of data from the underlying stream will be read.
679
+ #
680
+ # Will avoid reading from the underlying stream if there is buffered data available.
681
+ #
682
+ # @parameter length [Integer] The maximum number of bytes to read.
683
+ #
684
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:104
685
+ def read_partial(length = T.unsafe(nil), buffer = T.unsafe(nil)); end
686
+
687
+ # Read data from the stream until encountering pattern.
688
+ #
689
+ # @parameter pattern [String] The pattern to match.
690
+ # @parameter offset [Integer] The offset to start searching from.
691
+ # @parameter chomp [Boolean] Whether to remove the pattern from the returned data.
692
+ # @returns [String] The contents of the stream up until the pattern, which is consumed but not returned.
693
+ #
694
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:198
695
+ def read_until(pattern, offset = T.unsafe(nil), chomp: T.unsafe(nil)); end
696
+
697
+ # Similar to {read_partial} but raises an `EOFError` if the stream is at EOF.
698
+ #
699
+ # @parameter length [Integer] The maximum number of bytes to read.
700
+ # @parameter buffer [String] The buffer to read into.
701
+ #
702
+ # pkg:gem/protocol-http#lib/protocol/http/body/stream.rb:142
703
+ def readpartial(length, buffer = T.unsafe(nil)); end
704
+ end
705
+
706
+ # Wrapping body instance. Typically you'd override `#read`.
707
+ #
708
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:12
709
+ class Protocol::HTTP::Body::Wrapper < ::Protocol::HTTP::Body::Readable
710
+ # Initialize the wrapper with the given body.
711
+ #
712
+ # @parameter body [Readable] The body to wrap.
713
+ #
714
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:26
715
+ def initialize(body); end
716
+
717
+ # Convert the body to a hash suitable for serialization.
718
+ #
719
+ # @returns [Hash] The body as a hash.
720
+ #
721
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:86
722
+ def as_json(*, **, &); end
723
+
724
+ # @attribute [Readable] The wrapped body.
725
+ #
726
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:31
727
+ def body; end
728
+
729
+ # Forwards to the wrapped body.
730
+ #
731
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:54
732
+ def buffered; end
733
+
734
+ # Close the body.
735
+ #
736
+ # @parameter error [Exception | Nil] The error that caused this stream to be closed, if any.
737
+ #
738
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:36
739
+ def close(error = T.unsafe(nil)); end
740
+
741
+ # Forwards to the wrapped body.
742
+ #
743
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:79
744
+ def discard; end
745
+
746
+ # Forwards to the wrapped body.
747
+ #
748
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:44
749
+ def empty?; end
750
+
751
+ # Inspect the wrapped body. The wrapper, by default, is transparent.
752
+ #
753
+ # @returns [String] a string representation of the wrapped body.
754
+ #
755
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:103
756
+ def inspect; end
757
+
758
+ # Forwards to the wrapped body.
759
+ #
760
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:69
761
+ def length; end
762
+
763
+ # Forwards to the wrapped body.
764
+ #
765
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:74
766
+ def read; end
767
+
768
+ # Forwards to the wrapped body.
769
+ #
770
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:49
771
+ def ready?; end
772
+
773
+ # Forwards to the wrapped body.
774
+ #
775
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:59
776
+ def rewind; end
777
+
778
+ # Forwards to the wrapped body.
779
+ #
780
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:64
781
+ def rewindable?; end
782
+
783
+ # Convert the body to JSON.
784
+ #
785
+ # @returns [String] The body as JSON.
786
+ #
787
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:96
788
+ def to_json(*, **, &); end
789
+
790
+ class << self
791
+ # Wrap the body of the given message in a new instance of this class.
792
+ #
793
+ # @parameter message [Request | Response] the message to wrap.
794
+ # @returns [Wrapper | Nil] the wrapped body or `nil`` if the body was `nil`.
795
+ #
796
+ # pkg:gem/protocol-http#lib/protocol/http/body/wrapper.rb:17
797
+ def wrap(message); end
798
+ end
799
+ end
800
+
801
+ # A dynamic body which you can write to and read from.
802
+ #
803
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:12
804
+ class Protocol::HTTP::Body::Writable < ::Protocol::HTTP::Body::Readable
805
+ # Initialize the writable body.
806
+ #
807
+ # @parameter length [Integer] The length of the response body if known.
808
+ # @parameter queue [Thread::Queue] Specify a different queue implementation, e.g. `Thread::SizedQueue` to enable back-pressure.
809
+ #
810
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:21
811
+ def initialize(length = T.unsafe(nil), queue: T.unsafe(nil)); end
812
+
813
+ # Stop generating output; cause the next call to write to fail with the given error. Does not prevent existing chunks from being read. In other words, this indicates both that no more data will be or should be written to the body.
814
+ #
815
+ # @parameter error [Exception] The error that caused this body to be closed, if any. Will be raised on the next call to {read}.
816
+ #
817
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:37
818
+ def close(error = T.unsafe(nil)); end
819
+
820
+ # Signal that no more data will be written to the body.
821
+ #
822
+ # @parameter error [Exception] The error that caused this body to be closed, if any.
823
+ #
824
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:101
825
+ def close_write(error = T.unsafe(nil)); end
826
+
827
+ # Whether the body is closed. A closed body can not be written to or read from.
828
+ #
829
+ # @returns [Boolean] Whether the body is closed.
830
+ #
831
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:49
832
+ def closed?; end
833
+
834
+ # @attribute [Integer] The number of chunks written to the body.
835
+ #
836
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:32
837
+ def count; end
838
+
839
+ # Indicates whether the body is empty. This can occur if the body has been closed, or if the producer has invoked {close_write} and the reader has consumed all available chunks.
840
+ #
841
+ # @returns [Boolean] Whether the body is empty.
842
+ #
843
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:61
844
+ def empty?; end
845
+
846
+ # Inspect the body.
847
+ #
848
+ # @returns [String] A string representation of the body.
849
+ #
850
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:170
851
+ def inspect; end
852
+
853
+ # @attribute [Integer] The length of the response body if known.
854
+ #
855
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:29
856
+ def length; end
857
+
858
+ # Create an output wrapper which can be used to write chunks to the body.
859
+ #
860
+ # If a block is given, and the block raises an error, the error will used to close the body by invoking {close} with the error.
861
+ #
862
+ # @yields {|output| ...} if a block is given.
863
+ # @parameter output [Output] The output wrapper.
864
+ # @returns [Output] The output wrapper.
865
+ #
866
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:151
867
+ def output; end
868
+
869
+ # Read the next available chunk.
870
+ #
871
+ # @returns [String | Nil] The next chunk, or `nil` if the body is finished.
872
+ # @raises [Exception] If the body was closed due to an error.
873
+ #
874
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:69
875
+ def read; end
876
+
877
+ # @returns [Boolean] Whether the body is ready to be read from, without blocking.
878
+ #
879
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:54
880
+ def ready?; end
881
+
882
+ # Write a single chunk to the body. Signal completion by calling {close_write}.
883
+ #
884
+ # @parameter chunk [String] The chunk to write.
885
+ # @raises [Closed] If the body has been closed without error.
886
+ # @raises [Exception] If the body has been closed due to an error.
887
+ #
888
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:89
889
+ def write(chunk); end
890
+
891
+ private
892
+
893
+ # @returns [String] A string representation of the body's status.
894
+ #
895
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:181
896
+ def status; end
897
+ end
898
+
899
+ # An error indicating that the body has been closed and no further writes are allowed.
900
+ #
901
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:14
902
+ class Protocol::HTTP::Body::Writable::Closed < ::StandardError; end
903
+
904
+ # The output interface for writing chunks to the body.
905
+ #
906
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:107
907
+ class Protocol::HTTP::Body::Writable::Output
908
+ # Initialize the output with the given writable body.
909
+ #
910
+ # @parameter writable [Writable] The writable body.
911
+ #
912
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:111
913
+ def initialize(writable); end
914
+
915
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:126
916
+ def <<(chunk); end
917
+
918
+ # Close the output stream.
919
+ #
920
+ # If an error is given, the error will be used to close the body by invoking {close} with the error. Otherwise, only the write side of the body will be closed.
921
+ #
922
+ # @parameter error [Exception | Nil] The error that caused this stream to be closed, if any.
923
+ #
924
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:133
925
+ def close(error = T.unsafe(nil)); end
926
+
927
+ # @returns [Boolean] Whether the output is closed for writing only.
928
+ #
929
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:117
930
+ def closed?; end
931
+
932
+ # Write a chunk to the body.
933
+ #
934
+ # pkg:gem/protocol-http#lib/protocol/http/body/writable.rb:122
935
+ def write(chunk); end
936
+ end
937
+
938
+ # Represents an individual cookie key-value pair.
939
+ #
940
+ # pkg:gem/protocol-http#lib/protocol/http/cookie.rb:12
941
+ class Protocol::HTTP::Cookie
942
+ # Initialize the cookie with the given name, value, and directives.
943
+ #
944
+ # @parameter name [String] The name of the cookie, e.g. "session_id".
945
+ # @parameter value [String] The value of the cookie, e.g. "1234".
946
+ # @parameter directives [Hash] The directives of the cookie, e.g. `{"path" => "/"}`.
947
+ # @raises [ArgumentError] If the name or value contains invalid characters.
948
+ #
949
+ # pkg:gem/protocol-http#lib/protocol/http/cookie.rb:29
950
+ def initialize(name, value, directives = T.unsafe(nil)); end
951
+
952
+ # @attribute [Hash] The directives of the cookie.
953
+ #
954
+ # pkg:gem/protocol-http#lib/protocol/http/cookie.rb:50
955
+ def directives; end
956
+
957
+ # @attribute [Hash] The directives of the cookie.
958
+ #
959
+ # pkg:gem/protocol-http#lib/protocol/http/cookie.rb:50
960
+ def directives=(_arg0); end
961
+
962
+ # @attribute [String] The name of the cookie.
963
+ #
964
+ # pkg:gem/protocol-http#lib/protocol/http/cookie.rb:44
965
+ def name; end
966
+
967
+ # @attribute [String] The name of the cookie.
968
+ #
969
+ # pkg:gem/protocol-http#lib/protocol/http/cookie.rb:44
970
+ def name=(_arg0); end
971
+
972
+ # Convert the cookie to a string.
973
+ #
974
+ # @returns [String] The string representation of the cookie.
975
+ #
976
+ # pkg:gem/protocol-http#lib/protocol/http/cookie.rb:55
977
+ def to_s; end
978
+
979
+ # @attribute [String] The value of the cookie.
980
+ #
981
+ # pkg:gem/protocol-http#lib/protocol/http/cookie.rb:47
982
+ def value; end
983
+
984
+ # @attribute [String] The value of the cookie.
985
+ #
986
+ # pkg:gem/protocol-http#lib/protocol/http/cookie.rb:47
987
+ def value=(_arg0); end
988
+
989
+ class << self
990
+ # Parse a string into a cookie.
991
+ #
992
+ # @parameter string [String] The string to parse.
993
+ # @returns [Cookie] The parsed cookie.
994
+ #
995
+ # pkg:gem/protocol-http#lib/protocol/http/cookie.rb:78
996
+ def parse(string); end
997
+
998
+ # Parse a list of strings into a hash of directives.
999
+ #
1000
+ # @parameter strings [Array(String)] The list of strings to parse.
1001
+ # @returns [Hash] The hash of directives.
1002
+ #
1003
+ # pkg:gem/protocol-http#lib/protocol/http/cookie.rb:91
1004
+ def parse_directives(strings); end
1005
+ end
1006
+ end
1007
+
1008
+ # Valid cookie name characters according to RFC 6265.
1009
+ # cookie-name = token (RFC 2616 defines token)
1010
+ #
1011
+ # pkg:gem/protocol-http#lib/protocol/http/cookie.rb:15
1012
+ Protocol::HTTP::Cookie::VALID_COOKIE_KEY = T.let(T.unsafe(nil), Regexp)
1013
+
1014
+ # Valid cookie value characters according to RFC 6265.
1015
+ # cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )
1016
+ # cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E
1017
+ # Excludes control chars, whitespace, DQUOTE, comma, semicolon, and backslash
1018
+ #
1019
+ # pkg:gem/protocol-http#lib/protocol/http/cookie.rb:21
1020
+ Protocol::HTTP::Cookie::VALID_COOKIE_VALUE = T.let(T.unsafe(nil), Regexp)
1021
+
1022
+ # Raised when a singleton (e.g. `content-length`) header is duplicated in a request or response.
1023
+ #
1024
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:35
1025
+ class Protocol::HTTP::DuplicateHeaderError < ::Protocol::HTTP::InvalidHeaderError
1026
+ # @parameter key [String] The header key that was duplicated.
1027
+ #
1028
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:37
1029
+ def initialize(key, existing_value, new_value); end
1030
+
1031
+ # Provides a detailed error message including the existing and new values.
1032
+ # @parameter highlight [Boolean] Whether to highlight the message (not currently used).
1033
+ # @return [String] The detailed error message.
1034
+ #
1035
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:57
1036
+ def detailed_message(highlight: T.unsafe(nil)); end
1037
+
1038
+ # @attribute [String] existing_value The existing value for the duplicated header.
1039
+ #
1040
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:49
1041
+ def existing_value; end
1042
+
1043
+ # @attribute [String] key The header key that was duplicated.
1044
+ #
1045
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:46
1046
+ def key; end
1047
+
1048
+ # @attribute [String] new_value The new value for the duplicated header.
1049
+ #
1050
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:52
1051
+ def new_value; end
1052
+ end
1053
+
1054
+ # A generic, HTTP protocol error.
1055
+ #
1056
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:9
1057
+ class Protocol::HTTP::Error < ::StandardError; end
1058
+
1059
+ # @namespace
1060
+ #
1061
+ # pkg:gem/protocol-http#lib/protocol/http/header/split.rb:8
1062
+ module Protocol::HTTP::Header; end
1063
+
1064
+ # The `accept-content-type` header represents a list of content-types that the client can accept.
1065
+ #
1066
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:15
1067
+ class Protocol::HTTP::Header::Accept < ::Protocol::HTTP::Header::Split
1068
+ # Adds one or more comma-separated values to the header.
1069
+ #
1070
+ # The input string is split into distinct entries and appended to the array.
1071
+ #
1072
+ # @parameter value [String] a raw header value containing one or more media types separated by commas.
1073
+ #
1074
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:84
1075
+ def <<(value); end
1076
+
1077
+ # Parse the `accept` header.
1078
+ #
1079
+ # @returns [Array(Charset)] the list of content types and their associated parameters.
1080
+ #
1081
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:104
1082
+ def media_ranges; end
1083
+
1084
+ # Parse the `accept` header and order media ranges by preference.
1085
+ #
1086
+ # Media ranges with equal quality factors retain their original relative order.
1087
+ #
1088
+ # @returns [Array(MediaRange)] the preferred media ranges.
1089
+ #
1090
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:115
1091
+ def preferred_media_ranges; end
1092
+
1093
+ # The string representation of the media range, including the type, subtype, and any parameters.
1094
+ # Converts the parsed header value into a raw header value.
1095
+ #
1096
+ # @returns [String] a raw header value (comma-separated string).
1097
+ #
1098
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:91
1099
+ def to_s; end
1100
+
1101
+ private
1102
+
1103
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:121
1104
+ def parse_media_range(value); end
1105
+
1106
+ class << self
1107
+ # Parses a raw header value.
1108
+ #
1109
+ # @parameter value [String] a raw header value containing comma-separated media types.
1110
+ # @returns [Accept] a new instance containing the parsed media types.
1111
+ #
1112
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:75
1113
+ def parse(value); end
1114
+
1115
+ # Whether this header is acceptable in HTTP trailers.
1116
+ # @returns [Boolean] `false`, as Accept headers are used for response content negotiation.
1117
+ #
1118
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:97
1119
+ def trailer?; end
1120
+ end
1121
+ end
1122
+
1123
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:28
1124
+ Protocol::HTTP::Header::Accept::MEDIA_RANGE = T.let(T.unsafe(nil), Regexp)
1125
+
1126
+ # A single entry in the Accept: header, which includes a mime type and associated parameters. A media range can include wild cards, but a media type is a specific type and subtype.
1127
+ #
1128
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:33
1129
+ class Protocol::HTTP::Header::Accept::MediaRange < ::Struct
1130
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:39
1131
+ def initialize(type, subtype = T.unsafe(nil), parameters = T.unsafe(nil)); end
1132
+
1133
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:44
1134
+ def <=>(other); end
1135
+
1136
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:33
1137
+ def parameters; end
1138
+
1139
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:33
1140
+ def parameters=(_); end
1141
+
1142
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:66
1143
+ def quality_factor; end
1144
+
1145
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:33
1146
+ def subtype; end
1147
+
1148
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:33
1149
+ def subtype=(_); end
1150
+
1151
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:57
1152
+ def to_s; end
1153
+
1154
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:61
1155
+ def to_str; end
1156
+
1157
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:33
1158
+ def type; end
1159
+
1160
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:33
1161
+ def type=(_); end
1162
+
1163
+ private
1164
+
1165
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:48
1166
+ def parameters_string; end
1167
+
1168
+ class << self
1169
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:33
1170
+ def [](*_arg0); end
1171
+
1172
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:33
1173
+ def inspect; end
1174
+
1175
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:33
1176
+ def keyword_init?; end
1177
+
1178
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:33
1179
+ def members; end
1180
+
1181
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:33
1182
+ def new(*_arg0); end
1183
+ end
1184
+ end
1185
+
1186
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:30
1187
+ Protocol::HTTP::Header::Accept::PARAMETER = T.let(T.unsafe(nil), Regexp)
1188
+
1189
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:26
1190
+ class Protocol::HTTP::Header::Accept::ParseError < ::Protocol::HTTP::InvalidHeaderError; end
1191
+
1192
+ # Regular expression used to split values on commas, with optional surrounding whitespace, taking into account quoted strings.
1193
+ #
1194
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept.rb:17
1195
+ Protocol::HTTP::Header::Accept::SEPARATOR = T.let(T.unsafe(nil), Regexp)
1196
+
1197
+ # The `accept-charset` header represents a list of character sets that the client can accept.
1198
+ #
1199
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:14
1200
+ class Protocol::HTTP::Header::AcceptCharset < ::Protocol::HTTP::Header::Split
1201
+ # Parse the `accept-charset` header value into a list of character sets.
1202
+ #
1203
+ # @returns [Array(Charset)] the list of character sets and their associated quality factors.
1204
+ #
1205
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:41
1206
+ def charsets; end
1207
+
1208
+ # Parse the `accept-charset` header and order character sets by preference.
1209
+ #
1210
+ # Character sets with equal quality factors retain their original relative order.
1211
+ #
1212
+ # @returns [Array(Charset)] the preferred character sets.
1213
+ #
1214
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:56
1215
+ def preferred_charsets; end
1216
+ end
1217
+
1218
+ # https://tools.ietf.org/html/rfc7231#section-5.3.3
1219
+ #
1220
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:18
1221
+ Protocol::HTTP::Header::AcceptCharset::CHARSET = T.let(T.unsafe(nil), Regexp)
1222
+
1223
+ # A parsed character set entry with an optional quality factor.
1224
+ #
1225
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:21
1226
+ class Protocol::HTTP::Header::AcceptCharset::Charset < ::Struct
1227
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:33
1228
+ def <=>(other); end
1229
+
1230
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:21
1231
+ def name; end
1232
+
1233
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:21
1234
+ def name=(_); end
1235
+
1236
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:21
1237
+ def q; end
1238
+
1239
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:21
1240
+ def q=(_); end
1241
+
1242
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:25
1243
+ def quality_factor; end
1244
+
1245
+ class << self
1246
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:21
1247
+ def [](*_arg0); end
1248
+
1249
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:21
1250
+ def inspect; end
1251
+
1252
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:21
1253
+ def keyword_init?; end
1254
+
1255
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:21
1256
+ def members; end
1257
+
1258
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:21
1259
+ def new(*_arg0); end
1260
+ end
1261
+ end
1262
+
1263
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_charset.rb:15
1264
+ class Protocol::HTTP::Header::AcceptCharset::ParseError < ::Protocol::HTTP::InvalidHeaderError; end
1265
+
1266
+ # The `accept-encoding` header represents a list of encodings that the client can accept.
1267
+ #
1268
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:14
1269
+ class Protocol::HTTP::Header::AcceptEncoding < ::Protocol::HTTP::Header::Split
1270
+ # Parse the `accept-encoding` header value into a list of encodings.
1271
+ #
1272
+ # @returns [Array(Charset)] the list of character sets and their associated quality factors.
1273
+ #
1274
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:44
1275
+ def encodings; end
1276
+
1277
+ # Parse the `accept-encoding` header and order encodings by preference.
1278
+ #
1279
+ # Encodings with equal quality factors retain their original relative order.
1280
+ #
1281
+ # @returns [Array(Encoding)] the preferred encodings.
1282
+ #
1283
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:59
1284
+ def preferred_encodings; end
1285
+ end
1286
+
1287
+ # https://tools.ietf.org/html/rfc7231#section-5.3.4
1288
+ #
1289
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:21
1290
+ Protocol::HTTP::Header::AcceptEncoding::ENCODING = T.let(T.unsafe(nil), Regexp)
1291
+
1292
+ # A parsed content encoding entry with an optional quality factor.
1293
+ #
1294
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:24
1295
+ class Protocol::HTTP::Header::AcceptEncoding::Encoding < ::Struct
1296
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:36
1297
+ def <=>(other); end
1298
+
1299
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:24
1300
+ def name; end
1301
+
1302
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:24
1303
+ def name=(_); end
1304
+
1305
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:24
1306
+ def q; end
1307
+
1308
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:24
1309
+ def q=(_); end
1310
+
1311
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:28
1312
+ def quality_factor; end
1313
+
1314
+ class << self
1315
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:24
1316
+ def [](*_arg0); end
1317
+
1318
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:24
1319
+ def inspect; end
1320
+
1321
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:24
1322
+ def keyword_init?; end
1323
+
1324
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:24
1325
+ def members; end
1326
+
1327
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:24
1328
+ def new(*_arg0); end
1329
+ end
1330
+ end
1331
+
1332
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:15
1333
+ class Protocol::HTTP::Header::AcceptEncoding::ParseError < ::Protocol::HTTP::InvalidHeaderError; end
1334
+
1335
+ # https://tools.ietf.org/html/rfc7231#section-5.3.1
1336
+ #
1337
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_encoding.rb:18
1338
+ Protocol::HTTP::Header::AcceptEncoding::QVALUE = T.let(T.unsafe(nil), Regexp)
1339
+
1340
+ # The `accept-language` header represents a list of languages that the client can accept.
1341
+ #
1342
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:14
1343
+ class Protocol::HTTP::Header::AcceptLanguage < ::Protocol::HTTP::Header::Split
1344
+ # Parse the `accept-language` header value into a list of languages.
1345
+ #
1346
+ # @returns [Array(Charset)] the list of character sets and their associated quality factors.
1347
+ #
1348
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:47
1349
+ def languages; end
1350
+
1351
+ # Parse the `accept-language` header and order languages by preference.
1352
+ #
1353
+ # Languages with equal quality factors retain their original relative order.
1354
+ #
1355
+ # @returns [Array(Language)] the preferred languages.
1356
+ #
1357
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:62
1358
+ def preferred_languages; end
1359
+ end
1360
+
1361
+ # https://greenbytes.de/tech/webdav/rfc7231.html#quality.values
1362
+ #
1363
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:24
1364
+ Protocol::HTTP::Header::AcceptLanguage::LANGUAGE = T.let(T.unsafe(nil), Regexp)
1365
+
1366
+ # A parsed language entry with an optional quality factor.
1367
+ #
1368
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:27
1369
+ class Protocol::HTTP::Header::AcceptLanguage::Language < ::Struct
1370
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:39
1371
+ def <=>(other); end
1372
+
1373
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:27
1374
+ def name; end
1375
+
1376
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:27
1377
+ def name=(_); end
1378
+
1379
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:27
1380
+ def q; end
1381
+
1382
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:27
1383
+ def q=(_); end
1384
+
1385
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:31
1386
+ def quality_factor; end
1387
+
1388
+ class << self
1389
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:27
1390
+ def [](*_arg0); end
1391
+
1392
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:27
1393
+ def inspect; end
1394
+
1395
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:27
1396
+ def keyword_init?; end
1397
+
1398
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:27
1399
+ def members; end
1400
+
1401
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:27
1402
+ def new(*_arg0); end
1403
+ end
1404
+ end
1405
+
1406
+ # https://tools.ietf.org/html/rfc3066#section-2.1
1407
+ #
1408
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:18
1409
+ Protocol::HTTP::Header::AcceptLanguage::NAME = T.let(T.unsafe(nil), Regexp)
1410
+
1411
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:15
1412
+ class Protocol::HTTP::Header::AcceptLanguage::ParseError < ::Protocol::HTTP::InvalidHeaderError; end
1413
+
1414
+ # https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.9
1415
+ #
1416
+ # pkg:gem/protocol-http#lib/protocol/http/header/accept_language.rb:21
1417
+ Protocol::HTTP::Header::AcceptLanguage::QVALUE = T.let(T.unsafe(nil), Regexp)
1418
+
1419
+ # Used for basic authorization.
1420
+ #
1421
+ # ~~~ ruby
1422
+ # headers.add('authorization', Authorization.basic("my_username", "my_password"))
1423
+ # ~~~
1424
+ #
1425
+ # TODO Support other authorization mechanisms, e.g. bearer token.
1426
+ #
1427
+ # pkg:gem/protocol-http#lib/protocol/http/header/authorization.rb:17
1428
+ class Protocol::HTTP::Header::Authorization < ::String
1429
+ # Splits the header into the credentials.
1430
+ #
1431
+ # @returns [Tuple(String, String)] The username and password.
1432
+ #
1433
+ # pkg:gem/protocol-http#lib/protocol/http/header/authorization.rb:37
1434
+ def credentials; end
1435
+
1436
+ class << self
1437
+ # Generate a new basic authorization header, encoding the given username and password.
1438
+ #
1439
+ # @parameter username [String] The username.
1440
+ # @parameter password [String] The password.
1441
+ # @returns [Authorization] The basic authorization header.
1442
+ #
1443
+ # pkg:gem/protocol-http#lib/protocol/http/header/authorization.rb:46
1444
+ def basic(username, password); end
1445
+
1446
+ # Coerces a value into a parsed header object.
1447
+ #
1448
+ # @parameter value [String] the value to coerce.
1449
+ # @returns [Authorization] a parsed header object.
1450
+ #
1451
+ # pkg:gem/protocol-http#lib/protocol/http/header/authorization.rb:30
1452
+ def coerce(value); end
1453
+
1454
+ # Parses a raw header value.
1455
+ #
1456
+ # @parameter value [String] a raw header value.
1457
+ # @returns [Authorization] a new instance.
1458
+ #
1459
+ # pkg:gem/protocol-http#lib/protocol/http/header/authorization.rb:22
1460
+ def parse(value); end
1461
+
1462
+ # Whether this header is acceptable in HTTP trailers.
1463
+ # @returns [Boolean] `false`, as authorization headers are used for request authentication.
1464
+ #
1465
+ # pkg:gem/protocol-http#lib/protocol/http/header/authorization.rb:56
1466
+ def trailer?; end
1467
+ end
1468
+ end
1469
+
1470
+ # Represents the `cache-control` header, which is a list of cache directives.
1471
+ #
1472
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:13
1473
+ class Protocol::HTTP::Header::CacheControl < ::Protocol::HTTP::Header::Split
1474
+ # Adds a directive to the `cache-control` header. The value will be normalized to lowercase before being added.
1475
+ #
1476
+ # @parameter value [String] a raw header value containing directives to add.
1477
+ #
1478
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:71
1479
+ def <<(value); end
1480
+
1481
+ # @returns [Boolean] whether the `dynamic` directive is present.
1482
+ #
1483
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:81
1484
+ def dynamic?; end
1485
+
1486
+ # @returns [Integer | Nil] the value of the `max-age` directive in seconds, or `nil` if the directive is not present or invalid.
1487
+ #
1488
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:121
1489
+ def max_age; end
1490
+
1491
+ # @returns [Boolean] whether the `must-revalidate` directive is present.
1492
+ #
1493
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:111
1494
+ def must_revalidate?; end
1495
+
1496
+ # @returns [Boolean] whether the `no-cache` directive is present.
1497
+ #
1498
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:101
1499
+ def no_cache?; end
1500
+
1501
+ # @returns [Boolean] whether the `no-store` directive is present.
1502
+ #
1503
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:106
1504
+ def no_store?; end
1505
+
1506
+ # @returns [Boolean] whether the `private` directive is present.
1507
+ #
1508
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:91
1509
+ def private?; end
1510
+
1511
+ # @returns [Boolean] whether the `proxy-revalidate` directive is present.
1512
+ #
1513
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:116
1514
+ def proxy_revalidate?; end
1515
+
1516
+ # @returns [Boolean] whether the `public` directive is present.
1517
+ #
1518
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:96
1519
+ def public?; end
1520
+
1521
+ # @returns [Integer | Nil] the value of the `s-maxage` directive in seconds, or `nil` if the directive is not present or invalid.
1522
+ #
1523
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:126
1524
+ def s_maxage; end
1525
+
1526
+ # @returns [Boolean] whether the `static` directive is present.
1527
+ #
1528
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:76
1529
+ def static?; end
1530
+
1531
+ # @returns [Boolean] whether the `streaming` directive is present.
1532
+ #
1533
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:86
1534
+ def streaming?; end
1535
+
1536
+ private
1537
+
1538
+ # Finds and parses an integer value from a directive.
1539
+ #
1540
+ # @parameter value_name [String] the directive name to search for (e.g., "max-age").
1541
+ # @returns [Integer | Nil] the parsed integer value, or `nil` if not found or invalid.
1542
+ #
1543
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:136
1544
+ def find_integer_value(value_name); end
1545
+
1546
+ class << self
1547
+ # Coerces a value into a parsed header object.
1548
+ #
1549
+ # @parameter value [String | Array] the value to coerce.
1550
+ # @returns [CacheControl] a parsed header object with normalized values.
1551
+ #
1552
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:59
1553
+ def coerce(value); end
1554
+
1555
+ # Parses a raw header value.
1556
+ #
1557
+ # @parameter value [String] a raw header value containing comma-separated directives.
1558
+ # @returns [CacheControl] a new instance containing the parsed and normalized directives.
1559
+ #
1560
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:51
1561
+ def parse(value); end
1562
+ end
1563
+ end
1564
+
1565
+ # The `dynamic` directive is a custom directive used to indicate that the resource is generated dynamically and may change frequently, requiring shorter caching periods.
1566
+ #
1567
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:36
1568
+ Protocol::HTTP::Header::CacheControl::DYNAMIC = T.let(T.unsafe(nil), String)
1569
+
1570
+ # The `max-age` directive indicates the maximum amount of time, in seconds, that a response is considered fresh.
1571
+ #
1572
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:27
1573
+ Protocol::HTTP::Header::CacheControl::MAX_AGE = T.let(T.unsafe(nil), String)
1574
+
1575
+ # The `must-revalidate` directive indicates that once a response becomes stale, caches must not use it to satisfy subsequent requests without revalidating it with the origin server.
1576
+ #
1577
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:42
1578
+ Protocol::HTTP::Header::CacheControl::MUST_REVALIDATE = T.let(T.unsafe(nil), String)
1579
+
1580
+ # The `no-cache` directive indicates that caches must revalidate the response with the origin server before serving it to clients.
1581
+ #
1582
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:21
1583
+ Protocol::HTTP::Header::CacheControl::NO_CACHE = T.let(T.unsafe(nil), String)
1584
+
1585
+ # The `no-store` directive indicates that caches must not store the response under any circumstances.
1586
+ #
1587
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:24
1588
+ Protocol::HTTP::Header::CacheControl::NO_STORE = T.let(T.unsafe(nil), String)
1589
+
1590
+ # The `private` directive indicates that the response is intended for a single user and must not be stored by shared caches.
1591
+ #
1592
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:15
1593
+ Protocol::HTTP::Header::CacheControl::PRIVATE = T.let(T.unsafe(nil), String)
1594
+
1595
+ # The `proxy-revalidate` directive is similar to `must-revalidate` but applies only to shared caches.
1596
+ #
1597
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:45
1598
+ Protocol::HTTP::Header::CacheControl::PROXY_REVALIDATE = T.let(T.unsafe(nil), String)
1599
+
1600
+ # The `public` directive indicates that the response may be stored by any cache, even if it would normally be considered non-cacheable.
1601
+ #
1602
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:18
1603
+ Protocol::HTTP::Header::CacheControl::PUBLIC = T.let(T.unsafe(nil), String)
1604
+
1605
+ # The `static` directive is a custom directive often used to indicate that the resource is immutable or rarely changes, allowing longer caching periods.
1606
+ #
1607
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:33
1608
+ Protocol::HTTP::Header::CacheControl::STATIC = T.let(T.unsafe(nil), String)
1609
+
1610
+ # The `streaming` directive is a custom directive used to indicate that the resource is intended for progressive or chunked delivery, such as live video streams.
1611
+ #
1612
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:39
1613
+ Protocol::HTTP::Header::CacheControl::STREAMING = T.let(T.unsafe(nil), String)
1614
+
1615
+ # The `s-maxage` directive is similar to `max-age` but applies only to shared caches. If both `s-maxage` and `max-age` are present, `s-maxage` takes precedence in shared caches.
1616
+ #
1617
+ # pkg:gem/protocol-http#lib/protocol/http/header/cache_control.rb:30
1618
+ Protocol::HTTP::Header::CacheControl::S_MAXAGE = T.let(T.unsafe(nil), String)
1619
+
1620
+ # Represents the `connection` HTTP header, which controls options for the current connection.
1621
+ #
1622
+ # The `connection` header is used to specify control options such as whether the connection should be kept alive, closed, or upgraded to a different protocol.
1623
+ #
1624
+ # pkg:gem/protocol-http#lib/protocol/http/header/connection.rb:15
1625
+ class Protocol::HTTP::Header::Connection < ::Protocol::HTTP::Header::Split
1626
+ # Adds a directive to the `connection` header. The value will be normalized to lowercase before being added.
1627
+ #
1628
+ # @parameter value [String] a raw header value containing directives to add.
1629
+ #
1630
+ # pkg:gem/protocol-http#lib/protocol/http/header/connection.rb:49
1631
+ def <<(value); end
1632
+
1633
+ # @returns [Boolean] whether the `close` directive is present, indicating that the connection should be closed after the current request and response.
1634
+ #
1635
+ # pkg:gem/protocol-http#lib/protocol/http/header/connection.rb:59
1636
+ def close?; end
1637
+
1638
+ # @returns [Boolean] whether the `keep-alive` directive is present and the connection is not marked for closure with the `close` directive.
1639
+ #
1640
+ # pkg:gem/protocol-http#lib/protocol/http/header/connection.rb:54
1641
+ def keep_alive?; end
1642
+
1643
+ # @returns [Boolean] whether the `upgrade` directive is present, indicating that the connection should be upgraded to a different protocol.
1644
+ #
1645
+ # pkg:gem/protocol-http#lib/protocol/http/header/connection.rb:64
1646
+ def upgrade?; end
1647
+
1648
+ class << self
1649
+ # Coerces a value into a parsed header object.
1650
+ #
1651
+ # @parameter value [String | Array] the value to coerce.
1652
+ # @returns [Connection] a parsed header object with normalized values.
1653
+ #
1654
+ # pkg:gem/protocol-http#lib/protocol/http/header/connection.rb:37
1655
+ def coerce(value); end
1656
+
1657
+ # Parses a raw header value.
1658
+ #
1659
+ # @parameter value [String] a raw header value containing comma-separated directives.
1660
+ # @returns [Connection] a new instance with normalized (lowercase) directives.
1661
+ #
1662
+ # pkg:gem/protocol-http#lib/protocol/http/header/connection.rb:29
1663
+ def parse(value); end
1664
+
1665
+ # Whether this header is acceptable in HTTP trailers.
1666
+ # Connection headers control the current connection and must not appear in trailers.
1667
+ # @returns [Boolean] `false`, as connection headers are hop-by-hop and forbidden in trailers.
1668
+ #
1669
+ # pkg:gem/protocol-http#lib/protocol/http/header/connection.rb:71
1670
+ def trailer?; end
1671
+ end
1672
+ end
1673
+
1674
+ # The `close` directive indicates that the connection should be closed after the current request and response are complete.
1675
+ #
1676
+ # pkg:gem/protocol-http#lib/protocol/http/header/connection.rb:20
1677
+ Protocol::HTTP::Header::Connection::CLOSE = T.let(T.unsafe(nil), String)
1678
+
1679
+ # The `keep-alive` directive indicates that the connection should remain open for future requests or responses, avoiding the overhead of opening a new connection.
1680
+ #
1681
+ # pkg:gem/protocol-http#lib/protocol/http/header/connection.rb:17
1682
+ Protocol::HTTP::Header::Connection::KEEP_ALIVE = T.let(T.unsafe(nil), String)
1683
+
1684
+ # The `upgrade` directive indicates that the connection should be upgraded to a different protocol, as specified in the `Upgrade` header.
1685
+ #
1686
+ # pkg:gem/protocol-http#lib/protocol/http/header/connection.rb:23
1687
+ Protocol::HTTP::Header::Connection::UPGRADE = T.let(T.unsafe(nil), String)
1688
+
1689
+ # The `cookie` header contains stored HTTP cookies previously sent by the server with the `set-cookie` header.
1690
+ #
1691
+ # It is used by clients to send key-value pairs representing stored cookies back to the server.
1692
+ # Multiple cookies within a single `Cookie` header are joined with `"; "` per RFC 6265.
1693
+ #
1694
+ # pkg:gem/protocol-http#lib/protocol/http/header/cookie.rb:16
1695
+ class Protocol::HTTP::Header::Cookie < ::Array
1696
+ # Initializes the cookie header with the given values.
1697
+ #
1698
+ # @parameter value [Array | Nil] an array of cookie strings, or `nil` for an empty header.
1699
+ #
1700
+ # pkg:gem/protocol-http#lib/protocol/http/header/cookie.rb:41
1701
+ def initialize(value = T.unsafe(nil)); end
1702
+
1703
+ # Parses the `cookie` header into a hash of cookie names and their corresponding cookie objects.
1704
+ #
1705
+ # @returns [Hash(String, HTTP::Cookie)] a hash where keys are cookie names and values are {HTTP::Cookie} objects.
1706
+ #
1707
+ # pkg:gem/protocol-http#lib/protocol/http/header/cookie.rb:52
1708
+ def to_h; end
1709
+
1710
+ # Serializes the `cookie` header by joining individual cookie strings with `"; "` per RFC 6265.
1711
+ #
1712
+ # pkg:gem/protocol-http#lib/protocol/http/header/cookie.rb:64
1713
+ def to_s; end
1714
+
1715
+ class << self
1716
+ # Coerces a value into a parsed header object.
1717
+ #
1718
+ # @parameter value [String | Array] the value to coerce.
1719
+ # @returns [Cookie] a parsed header object.
1720
+ #
1721
+ # pkg:gem/protocol-http#lib/protocol/http/header/cookie.rb:29
1722
+ def coerce(value); end
1723
+
1724
+ # Parses a raw header value.
1725
+ #
1726
+ # @parameter value [String] a single raw header value.
1727
+ # @returns [Cookie] a new instance containing the parsed value.
1728
+ #
1729
+ # pkg:gem/protocol-http#lib/protocol/http/header/cookie.rb:21
1730
+ def parse(value); end
1731
+
1732
+ # Whether this header is acceptable in HTTP trailers.
1733
+ # Cookie headers should not appear in trailers as they contain state information needed early in processing.
1734
+ # @returns [Boolean] `false`, as cookie headers are needed during initial request processing.
1735
+ #
1736
+ # pkg:gem/protocol-http#lib/protocol/http/header/cookie.rb:71
1737
+ def trailer?; end
1738
+ end
1739
+ end
1740
+
1741
+ # The `date` header represents the date and time at which the message was originated.
1742
+ #
1743
+ # This header is typically included in HTTP responses and follows the format defined in RFC 9110.
1744
+ #
1745
+ # pkg:gem/protocol-http#lib/protocol/http/header/date.rb:14
1746
+ class Protocol::HTTP::Header::Date < ::String
1747
+ # Replaces the current value of the `date` header.
1748
+ #
1749
+ # @parameter value [String] a raw header value for the `date` header.
1750
+ #
1751
+ # pkg:gem/protocol-http#lib/protocol/http/header/date.rb:34
1752
+ def <<(value); end
1753
+
1754
+ # Converts the `date` header value to a `Time` object.
1755
+ #
1756
+ # @returns [Time] the parsed time object corresponding to the `date` header value.
1757
+ #
1758
+ # pkg:gem/protocol-http#lib/protocol/http/header/date.rb:41
1759
+ def to_time; end
1760
+
1761
+ class << self
1762
+ # Coerces a value into a parsed header object.
1763
+ #
1764
+ # @parameter value [String] the value to coerce.
1765
+ # @returns [Date] a parsed header object.
1766
+ #
1767
+ # pkg:gem/protocol-http#lib/protocol/http/header/date.rb:27
1768
+ def coerce(value); end
1769
+
1770
+ # Parses a raw header value.
1771
+ #
1772
+ # @parameter value [String] a raw header value.
1773
+ # @returns [Date] a new instance.
1774
+ #
1775
+ # pkg:gem/protocol-http#lib/protocol/http/header/date.rb:19
1776
+ def parse(value); end
1777
+
1778
+ # Whether this header is acceptable in HTTP trailers.
1779
+ # Date headers can safely appear in trailers as they provide metadata about response generation.
1780
+ # @returns [Boolean] `true`, as date headers are metadata that can be computed after response generation.
1781
+ #
1782
+ # pkg:gem/protocol-http#lib/protocol/http/header/date.rb:48
1783
+ def trailer?; end
1784
+ end
1785
+ end
1786
+
1787
+ # The `digest` header provides a digest of the message body for integrity verification.
1788
+ #
1789
+ # This header allows servers to send cryptographic hashes of the response body, enabling clients to verify data integrity. Multiple digest algorithms can be specified, and the header is particularly useful as a trailer since the digest can only be computed after the entire message body is available.
1790
+ #
1791
+ # ## Examples
1792
+ #
1793
+ # ```ruby
1794
+ # digest = Digest.new("sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=")
1795
+ # digest << "md5=9bb58f26192e4ba00f01e2e7b136bbd8"
1796
+ # puts digest.to_s
1797
+ # # => "sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=, md5=9bb58f26192e4ba00f01e2e7b136bbd8"
1798
+ # ```
1799
+ #
1800
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:25
1801
+ class Protocol::HTTP::Header::Digest < ::Protocol::HTTP::Header::Split
1802
+ # Parse the `digest` header value into a list of digest entries.
1803
+ #
1804
+ # @returns [Array(Entry)] the list of digest entries with their algorithms and values.
1805
+ #
1806
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:52
1807
+ def entries; end
1808
+
1809
+ class << self
1810
+ # Whether this header is acceptable in HTTP trailers.
1811
+ # @returns [Boolean] `true`, as digest headers contain integrity hashes that can only be calculated after the entire message body is available.
1812
+ #
1813
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:64
1814
+ def trailer?; end
1815
+ end
1816
+ end
1817
+
1818
+ # https://tools.ietf.org/html/rfc3230#section-4.3.2
1819
+ #
1820
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:29
1821
+ Protocol::HTTP::Header::Digest::ENTRY = T.let(T.unsafe(nil), Regexp)
1822
+
1823
+ # A single digest entry in the Digest header.
1824
+ #
1825
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:32
1826
+ class Protocol::HTTP::Header::Digest::Entry < ::Struct
1827
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:37
1828
+ def initialize(algorithm, value); end
1829
+
1830
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:32
1831
+ def algorithm; end
1832
+
1833
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:32
1834
+ def algorithm=(_); end
1835
+
1836
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:44
1837
+ def to_s; end
1838
+
1839
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:32
1840
+ def value; end
1841
+
1842
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:32
1843
+ def value=(_); end
1844
+
1845
+ class << self
1846
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:32
1847
+ def [](*_arg0); end
1848
+
1849
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:32
1850
+ def inspect; end
1851
+
1852
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:32
1853
+ def keyword_init?; end
1854
+
1855
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:32
1856
+ def members; end
1857
+
1858
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:32
1859
+ def new(*_arg0); end
1860
+ end
1861
+ end
1862
+
1863
+ # pkg:gem/protocol-http#lib/protocol/http/header/digest.rb:26
1864
+ class Protocol::HTTP::Header::Digest::ParseError < ::Protocol::HTTP::InvalidHeaderError; end
1865
+
1866
+ # The `etag` header represents the entity tag for a resource.
1867
+ #
1868
+ # The `etag` header provides a unique identifier for a specific version of a resource, typically used for cache validation or conditional requests. It can be either a strong or weak validator as defined in RFC 9110.
1869
+ #
1870
+ # pkg:gem/protocol-http#lib/protocol/http/header/etag.rb:12
1871
+ class Protocol::HTTP::Header::ETag < ::String
1872
+ # Replaces the current value of the `etag` header.
1873
+ #
1874
+ # @parameter value [String] a raw header value for the `etag` header.
1875
+ #
1876
+ # pkg:gem/protocol-http#lib/protocol/http/header/etag.rb:32
1877
+ def <<(value); end
1878
+
1879
+ # Checks whether the `etag` is a weak validator.
1880
+ #
1881
+ # Weak validators indicate semantically equivalent content but may not be byte-for-byte identical.
1882
+ #
1883
+ # @returns [Boolean] whether the `etag` is weak.
1884
+ #
1885
+ # pkg:gem/protocol-http#lib/protocol/http/header/etag.rb:41
1886
+ def weak?; end
1887
+
1888
+ class << self
1889
+ # Coerces a value into a parsed header object.
1890
+ #
1891
+ # @parameter value [String] the value to coerce.
1892
+ # @returns [ETag] a parsed header object.
1893
+ #
1894
+ # pkg:gem/protocol-http#lib/protocol/http/header/etag.rb:25
1895
+ def coerce(value); end
1896
+
1897
+ # Parses a raw header value.
1898
+ #
1899
+ # @parameter value [String] a raw header value.
1900
+ # @returns [ETag] a new instance.
1901
+ #
1902
+ # pkg:gem/protocol-http#lib/protocol/http/header/etag.rb:17
1903
+ def parse(value); end
1904
+
1905
+ # Whether this header is acceptable in HTTP trailers.
1906
+ # ETag headers can safely appear in trailers as they provide cache validation metadata.
1907
+ # @returns [Boolean] `true`, as ETag headers are metadata that can be computed after response generation.
1908
+ #
1909
+ # pkg:gem/protocol-http#lib/protocol/http/header/etag.rb:48
1910
+ def trailer?; end
1911
+ end
1912
+ end
1913
+
1914
+ # The `etags` header represents a list of entity tags (ETags) for resources.
1915
+ #
1916
+ # The `etags` header is used for conditional requests to compare the current version of a resource with previously stored versions. It supports both strong and weak validators, as well as the wildcard character (`*`) to indicate a match for any resource.
1917
+ #
1918
+ # pkg:gem/protocol-http#lib/protocol/http/header/etags.rb:15
1919
+ class Protocol::HTTP::Header::ETags < ::Protocol::HTTP::Header::Split
1920
+ # Checks if the specified ETag matches the `etags` header.
1921
+ #
1922
+ # This method returns `true` if the wildcard is present or if the exact ETag is found in the list. Note that this implementation is not strictly compliant with the RFC-specified format.
1923
+ #
1924
+ # @parameter etag [String] the ETag to compare against the `etags` header.
1925
+ # @returns [Boolean] whether the specified ETag matches.
1926
+ #
1927
+ # pkg:gem/protocol-http#lib/protocol/http/header/etags.rb:31
1928
+ def match?(etag); end
1929
+
1930
+ # Checks for a strong match with the specified ETag, useful with the `if-match` header.
1931
+ #
1932
+ # A strong match requires that the ETag in the header list matches the specified ETag and that neither is a weak validator.
1933
+ #
1934
+ # @parameter etag [String] the ETag to compare against the `etags` header.
1935
+ # @returns [Boolean] whether a strong match is found.
1936
+ #
1937
+ # pkg:gem/protocol-http#lib/protocol/http/header/etags.rb:41
1938
+ def strong_match?(etag); end
1939
+
1940
+ # Checks for a weak match with the specified ETag, useful with the `if-none-match` header.
1941
+ #
1942
+ # A weak match allows for semantically equivalent content, including weak validators and their strong counterparts.
1943
+ #
1944
+ # @parameter etag [String] the ETag to compare against the `etags` header.
1945
+ # @returns [Boolean] whether a weak match is found.
1946
+ #
1947
+ # pkg:gem/protocol-http#lib/protocol/http/header/etags.rb:51
1948
+ def weak_match?(etag); end
1949
+
1950
+ # Checks if the `etags` header contains the wildcard (`*`) character.
1951
+ #
1952
+ # The wildcard character matches any resource version, regardless of its actual value.
1953
+ #
1954
+ # @returns [Boolean] whether the wildcard is present.
1955
+ #
1956
+ # pkg:gem/protocol-http#lib/protocol/http/header/etags.rb:21
1957
+ def wildcard?; end
1958
+
1959
+ private
1960
+
1961
+ # Converts a weak tag to its strong counterpart or vice versa.
1962
+ #
1963
+ # @parameter etag [String] the ETag to convert.
1964
+ # @returns [String] the opposite form of the provided ETag.
1965
+ #
1966
+ # pkg:gem/protocol-http#lib/protocol/http/header/etags.rb:61
1967
+ def opposite_tag(etag); end
1968
+
1969
+ # Checks if the given ETag is a weak validator.
1970
+ #
1971
+ # @parameter tag [String] the ETag to check.
1972
+ # @returns [Boolean] whether the tag is weak.
1973
+ #
1974
+ # pkg:gem/protocol-http#lib/protocol/http/header/etags.rb:69
1975
+ def weak_tag?(tag); end
1976
+ end
1977
+
1978
+ # Represents generic or custom headers that can be used in trailers.
1979
+ #
1980
+ # This class is used as the default policy for headers not explicitly defined in the POLICY hash.
1981
+ #
1982
+ # It allows generic headers to be used in HTTP trailers, which is important for:
1983
+ # - Custom application headers.
1984
+ # - gRPC status headers (grpc-status, grpc-message).
1985
+ # - Headers used by proxies and middleware.
1986
+ # - Future HTTP extensions.
1987
+ #
1988
+ # pkg:gem/protocol-http#lib/protocol/http/header/generic.rb:20
1989
+ class Protocol::HTTP::Header::Generic < ::Protocol::HTTP::Header::Split
1990
+ class << self
1991
+ # Whether this header is acceptable in HTTP trailers.
1992
+ # Generic headers are allowed in trailers by default to support extensibility.
1993
+ # @returns [Boolean] `true`, generic headers are allowed in trailers.
1994
+ #
1995
+ # pkg:gem/protocol-http#lib/protocol/http/header/generic.rb:24
1996
+ def trailer?; end
1997
+ end
1998
+ end
1999
+
2000
+ # Represents headers that can contain multiple distinct values separated by newline characters.
2001
+ #
2002
+ # This isn't a specific header but is used as a base for headers that store multiple values, such as cookies. The values are split and stored as an array internally, and serialized back to a newline-separated string when needed.
2003
+ #
2004
+ # pkg:gem/protocol-http#lib/protocol/http/header/multiple.rb:12
2005
+ class Protocol::HTTP::Header::Multiple < ::Array
2006
+ # Initializes the multiple header with the given values.
2007
+ #
2008
+ # @parameter value [Array | Nil] an array of header values, or `nil` for an empty header.
2009
+ #
2010
+ # pkg:gem/protocol-http#lib/protocol/http/header/multiple.rb:41
2011
+ def initialize(value = T.unsafe(nil)); end
2012
+
2013
+ # Converts the parsed header value into a raw header value.
2014
+ #
2015
+ # Multiple headers are transmitted as separate header entries, so this serializes to a newline-separated string for storage.
2016
+ #
2017
+ # @returns [String] a raw header value (newline-separated string).
2018
+ #
2019
+ # pkg:gem/protocol-http#lib/protocol/http/header/multiple.rb:54
2020
+ def to_s; end
2021
+
2022
+ class << self
2023
+ # Coerces a value into a parsed header object.
2024
+ #
2025
+ # This method is used by the Headers class when setting values via `[]=` to convert application values into the appropriate policy type.
2026
+ #
2027
+ # @parameter value [String | Array] the value to coerce.
2028
+ # @returns [Multiple] a parsed header object.
2029
+ #
2030
+ # pkg:gem/protocol-http#lib/protocol/http/header/multiple.rb:29
2031
+ def coerce(value); end
2032
+
2033
+ # Parses a raw header value.
2034
+ #
2035
+ # Multiple headers receive each value as a separate header entry, so this method takes a single string value and creates a new instance containing it.
2036
+ #
2037
+ # @parameter value [String] a single raw header value.
2038
+ # @returns [Multiple] a new instance containing the parsed value.
2039
+ #
2040
+ # pkg:gem/protocol-http#lib/protocol/http/header/multiple.rb:19
2041
+ def parse(value); end
2042
+
2043
+ # Whether this header is acceptable in HTTP trailers.
2044
+ # This is a base class for headers with multiple values, default is to disallow in trailers.
2045
+ # @returns [Boolean] `false`, as most multiple-value headers should not appear in trailers by default.
2046
+ #
2047
+ # pkg:gem/protocol-http#lib/protocol/http/header/multiple.rb:61
2048
+ def trailer?; end
2049
+ end
2050
+ end
2051
+
2052
+ # Represents the `priority` header, used to indicate the relative importance of an HTTP request.
2053
+ #
2054
+ # The `priority` header allows clients to express their preference for how resources should be prioritized by the server. It supports directives like `u=` to specify the urgency level of a request, and `i` to indicate whether a response can be delivered incrementally. The urgency levels range from 0 (highest priority) to 7 (lowest priority), while the `i` directive is a boolean flag.
2055
+ #
2056
+ # pkg:gem/protocol-http#lib/protocol/http/header/priority.rb:14
2057
+ class Protocol::HTTP::Header::Priority < ::Protocol::HTTP::Header::Split
2058
+ # Add a value to the priority header.
2059
+ #
2060
+ # @parameter value [String] a raw header value containing directives to add to the header.
2061
+ #
2062
+ # pkg:gem/protocol-http#lib/protocol/http/header/priority.rb:39
2063
+ def <<(value); end
2064
+
2065
+ # Checks if the response should be delivered incrementally.
2066
+ #
2067
+ # The `i` directive, when present, indicates that the response can be delivered incrementally as data becomes available.
2068
+ #
2069
+ # @returns [Boolean] whether the request should be delivered incrementally.
2070
+ #
2071
+ # pkg:gem/protocol-http#lib/protocol/http/header/priority.rb:65
2072
+ def incremental?; end
2073
+
2074
+ # The urgency level, if specified using `u=`. 0 is the highest priority, and 7 is the lowest.
2075
+ #
2076
+ # Note that when duplicate Dictionary keys are encountered, all but the last instance are ignored.
2077
+ #
2078
+ # @returns [Integer | Nil] the urgency level if specified, or `nil` if not present.
2079
+ #
2080
+ # pkg:gem/protocol-http#lib/protocol/http/header/priority.rb:51
2081
+ def urgency(default = T.unsafe(nil)); end
2082
+
2083
+ class << self
2084
+ # Coerces a value into a parsed header object.
2085
+ #
2086
+ # @parameter value [String | Array] the value to coerce.
2087
+ # @returns [Priority] a parsed header object with normalized values.
2088
+ #
2089
+ # pkg:gem/protocol-http#lib/protocol/http/header/priority.rb:27
2090
+ def coerce(value); end
2091
+
2092
+ # Parses a raw header value.
2093
+ #
2094
+ # @parameter value [String] a raw header value containing comma-separated directives.
2095
+ # @returns [Priority] a new instance with normalized (lowercase) directives.
2096
+ #
2097
+ # pkg:gem/protocol-http#lib/protocol/http/header/priority.rb:19
2098
+ def parse(value); end
2099
+ end
2100
+ end
2101
+
2102
+ # The default urgency level if not specified.
2103
+ #
2104
+ # pkg:gem/protocol-http#lib/protocol/http/header/priority.rb:44
2105
+ Protocol::HTTP::Header::Priority::DEFAULT_URGENCY = T.let(T.unsafe(nil), Integer)
2106
+
2107
+ # Represents a `range` request header.
2108
+ #
2109
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:12
2110
+ class Protocol::HTTP::Header::Range
2111
+ # Initialize a range header.
2112
+ # @parameter unit [String] The range unit.
2113
+ # @parameter ranges [Array] The range specifiers.
2114
+ #
2115
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:106
2116
+ def initialize(unit, ranges); end
2117
+
2118
+ # Combine another raw range header value with this one.
2119
+ # @parameter value [String] The raw range header value.
2120
+ #
2121
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:139
2122
+ def <<(value); end
2123
+
2124
+ # Whether this header contains byte ranges.
2125
+ # @returns [Boolean] Whether the range unit is `bytes`.
2126
+ #
2127
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:119
2128
+ def bytes?; end
2129
+
2130
+ # @attribute [Array] The range specifiers.
2131
+ #
2132
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:115
2133
+ def ranges; end
2134
+
2135
+ # Resolve this byte range against the selected representation size.
2136
+ # @parameter size [Integer] The size of the selected representation.
2137
+ # @returns [::Range | Nil] The resolved range, or `nil` when it is unsatisfiable.
2138
+ # Resolve all byte ranges against the selected representation size.
2139
+ # @parameter size [Integer] The size of the selected representation.
2140
+ # @returns [Array(::Range)] The satisfiable byte ranges.
2141
+ #
2142
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:126
2143
+ def resolve(size); end
2144
+
2145
+ # Convert this byte range to its wire representation.
2146
+ # @returns [String] The serialized byte range.
2147
+ # Convert this header to its wire representation.
2148
+ # @returns [String] The serialized range header.
2149
+ #
2150
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:153
2151
+ def to_s; end
2152
+
2153
+ # @attribute [String] The range unit.
2154
+ #
2155
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:112
2156
+ def unit; end
2157
+
2158
+ class << self
2159
+ # Coerce a value into a range header.
2160
+ # @parameter value [Object] The value to coerce.
2161
+ # @returns [Range] The parsed range header.
2162
+ #
2163
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:99
2164
+ def coerce(value); end
2165
+
2166
+ # Parse a raw range header value.
2167
+ # @parameter value [String] The raw header value.
2168
+ # @returns [Range] The parsed range header.
2169
+ # Parse one byte range.
2170
+ # @parameter value [String] The byte range to parse.
2171
+ # @returns [ByteRange] The parsed byte range.
2172
+ #
2173
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:75
2174
+ def parse(value); end
2175
+
2176
+ # Whether this header is acceptable in HTTP trailers.
2177
+ # @returns [Boolean] `false`, as range headers apply to a selected representation.
2178
+ #
2179
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:159
2180
+ def trailer?; end
2181
+ end
2182
+ end
2183
+
2184
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:17
2185
+ Protocol::HTTP::Header::Range::BYTE_RANGE = T.let(T.unsafe(nil), Regexp)
2186
+
2187
+ # Represents one byte-range-spec or suffix-byte-range-spec.
2188
+ #
2189
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:22
2190
+ class Protocol::HTTP::Header::Range::ByteRange < ::Struct
2191
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:22
2192
+ def first; end
2193
+
2194
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:22
2195
+ def first=(_); end
2196
+
2197
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:22
2198
+ def last; end
2199
+
2200
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:22
2201
+ def last=(_); end
2202
+
2203
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:49
2204
+ def resolve(size); end
2205
+
2206
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:63
2207
+ def to_s; end
2208
+
2209
+ class << self
2210
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:22
2211
+ def [](*_arg0); end
2212
+
2213
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:22
2214
+ def inspect; end
2215
+
2216
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:22
2217
+ def keyword_init?; end
2218
+
2219
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:22
2220
+ def members; end
2221
+
2222
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:22
2223
+ def new(*_arg0); end
2224
+
2225
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:26
2226
+ def parse(value); end
2227
+ end
2228
+ end
2229
+
2230
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:16
2231
+ Protocol::HTTP::Header::Range::HEADER = T.let(T.unsafe(nil), Regexp)
2232
+
2233
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:18
2234
+ Protocol::HTTP::Header::Range::OTHER_RANGE = T.let(T.unsafe(nil), Regexp)
2235
+
2236
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:13
2237
+ class Protocol::HTTP::Header::Range::ParseError < ::Protocol::HTTP::InvalidHeaderError; end
2238
+
2239
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:19
2240
+ Protocol::HTTP::Header::Range::SEPARATOR = T.let(T.unsafe(nil), Regexp)
2241
+
2242
+ # pkg:gem/protocol-http#lib/protocol/http/header/range.rb:15
2243
+ Protocol::HTTP::Header::Range::TOKEN = T.let(T.unsafe(nil), Regexp)
2244
+
2245
+ # The `server-timing` header communicates performance metrics about the request-response cycle to the client.
2246
+ #
2247
+ # This header allows servers to send timing information about various server-side operations, which can be useful for performance monitoring and debugging. Each metric can include a name, optional duration, and optional description.
2248
+ #
2249
+ # ## Examples
2250
+ #
2251
+ # ```ruby
2252
+ # server_timing = ServerTiming.new("db;dur=53.2")
2253
+ # server_timing << "cache;dur=12.1;desc=\"Redis lookup\""
2254
+ # puts server_timing.to_s
2255
+ # # => "db;dur=53.2, cache;dur=12.1;desc=\"Redis lookup\""
2256
+ # ```
2257
+ #
2258
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:25
2259
+ class Protocol::HTTP::Header::ServerTiming < ::Protocol::HTTP::Header::Split
2260
+ # Parse the `server-timing` header value into a list of metrics.
2261
+ #
2262
+ # @returns [Array(Metric)] the list of metrics with their names, durations, and descriptions.
2263
+ #
2264
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:57
2265
+ def metrics; end
2266
+
2267
+ class << self
2268
+ # Whether this header is acceptable in HTTP trailers.
2269
+ # @returns [Boolean] `true`, as server-timing headers contain performance metrics that are typically calculated during response generation.
2270
+ #
2271
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:86
2272
+ def trailer?; end
2273
+ end
2274
+ end
2275
+
2276
+ # https://www.w3.org/TR/server-timing/
2277
+ #
2278
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:29
2279
+ Protocol::HTTP::Header::ServerTiming::METRIC = T.let(T.unsafe(nil), Regexp)
2280
+
2281
+ # A single metric in the Server-Timing header.
2282
+ #
2283
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:33
2284
+ class Protocol::HTTP::Header::ServerTiming::Metric < ::Struct
2285
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:39
2286
+ def initialize(name, duration = T.unsafe(nil), description = T.unsafe(nil)); end
2287
+
2288
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:33
2289
+ def description; end
2290
+
2291
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:33
2292
+ def description=(_); end
2293
+
2294
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:33
2295
+ def duration; end
2296
+
2297
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:33
2298
+ def duration=(_); end
2299
+
2300
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:33
2301
+ def name; end
2302
+
2303
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:33
2304
+ def name=(_); end
2305
+
2306
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:46
2307
+ def to_s; end
2308
+
2309
+ class << self
2310
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:33
2311
+ def [](*_arg0); end
2312
+
2313
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:33
2314
+ def inspect; end
2315
+
2316
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:33
2317
+ def keyword_init?; end
2318
+
2319
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:33
2320
+ def members; end
2321
+
2322
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:33
2323
+ def new(*_arg0); end
2324
+ end
2325
+ end
2326
+
2327
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:30
2328
+ Protocol::HTTP::Header::ServerTiming::PARAMETER = T.let(T.unsafe(nil), Regexp)
2329
+
2330
+ # pkg:gem/protocol-http#lib/protocol/http/header/server_timing.rb:26
2331
+ class Protocol::HTTP::Header::ServerTiming::ParseError < ::Protocol::HTTP::InvalidHeaderError; end
2332
+
2333
+ # The `set-cookie` header sends cookies from the server to the user agent.
2334
+ #
2335
+ # Each `Set-Cookie` header must be a separate header field — they cannot be combined.
2336
+ # It is used to store cookies on the client side, which are then sent back to the server
2337
+ # in subsequent requests using the `cookie` header.
2338
+ #
2339
+ # pkg:gem/protocol-http#lib/protocol/http/header/set_cookie.rb:18
2340
+ class Protocol::HTTP::Header::SetCookie < ::Protocol::HTTP::Header::Multiple
2341
+ # Parses the `set-cookie` headers into a hash of cookie names and their corresponding cookie objects.
2342
+ #
2343
+ # @returns [Hash(String, HTTP::Cookie)] a hash where keys are cookie names and values are {HTTP::Cookie} objects.
2344
+ #
2345
+ # pkg:gem/protocol-http#lib/protocol/http/header/set_cookie.rb:22
2346
+ def to_h; end
2347
+
2348
+ class << self
2349
+ # Whether this header is acceptable in HTTP trailers.
2350
+ # @returns [Boolean] `false`, as set-cookie headers are needed during initial response processing.
2351
+ #
2352
+ # pkg:gem/protocol-http#lib/protocol/http/header/set_cookie.rb:32
2353
+ def trailer?; end
2354
+ end
2355
+ end
2356
+
2357
+ # Represents headers that can contain multiple distinct values separated by commas.
2358
+ #
2359
+ # This isn't a specific header class is a utility for handling headers with comma-separated values, such as `accept`, `cache-control`, and other similar headers. The values are split and stored as an array internally, and serialized back to a comma-separated string when needed.
2360
+ #
2361
+ # pkg:gem/protocol-http#lib/protocol/http/header/split.rb:12
2362
+ class Protocol::HTTP::Header::Split < ::Array
2363
+ # Initializes a `Split` header with the given values.
2364
+ #
2365
+ # @parameter value [Array | String | Nil] an array of values, a raw header value, or `nil` for an empty header.
2366
+ #
2367
+ # pkg:gem/protocol-http#lib/protocol/http/header/split.rb:44
2368
+ def initialize(value = T.unsafe(nil)); end
2369
+
2370
+ # Adds one or more comma-separated values to the header.
2371
+ #
2372
+ # The input string is split into distinct entries and appended to the array.
2373
+ #
2374
+ # @parameter value [String] a raw header value containing one or more values separated by commas.
2375
+ #
2376
+ # pkg:gem/protocol-http#lib/protocol/http/header/split.rb:61
2377
+ def <<(value); end
2378
+
2379
+ # Converts the parsed header value into a raw header value.
2380
+ #
2381
+ # @returns [String] a raw header value (comma-separated string).
2382
+ #
2383
+ # pkg:gem/protocol-http#lib/protocol/http/header/split.rb:68
2384
+ def to_s; end
2385
+
2386
+ protected
2387
+
2388
+ # pkg:gem/protocol-http#lib/protocol/http/header/split.rb:89
2389
+ def reverse_find(&block); end
2390
+
2391
+ # Order weighted values by descending quality while preserving their relative order.
2392
+ # @parameter values [Enumerable] The values which respond to `#quality_factor`.
2393
+ # @returns [Array] The ordered values.
2394
+ #
2395
+ # pkg:gem/protocol-http#lib/protocol/http/header/split.rb:83
2396
+ def sort_by_quality_factor(values); end
2397
+
2398
+ class << self
2399
+ # Coerces a value into a parsed header object.
2400
+ #
2401
+ # This method is used by the Headers class when setting values via `[]=` to convert application values into the appropriate policy type.
2402
+ #
2403
+ # @parameter value [String | Array] the value to coerce.
2404
+ # @returns [Split] a parsed header object.
2405
+ #
2406
+ # pkg:gem/protocol-http#lib/protocol/http/header/split.rb:32
2407
+ def coerce(value); end
2408
+
2409
+ # Parses a raw header value.
2410
+ #
2411
+ # Split headers receive comma-separated values in a single header entry. This method splits the raw value into individual entries.
2412
+ #
2413
+ # @parameter value [String] a raw header value containing multiple entries separated by commas.
2414
+ # @returns [Split] a new instance containing the parsed values.
2415
+ #
2416
+ # pkg:gem/protocol-http#lib/protocol/http/header/split.rb:22
2417
+ def parse(value); end
2418
+
2419
+ # Whether this header is acceptable in HTTP trailers.
2420
+ # This is a base class for comma-separated headers, default is to disallow in trailers.
2421
+ # @returns [Boolean] `false`, as most comma-separated headers should not appear in trailers by default.
2422
+ #
2423
+ # pkg:gem/protocol-http#lib/protocol/http/header/split.rb:75
2424
+ def trailer?; end
2425
+ end
2426
+ end
2427
+
2428
+ # Regular expression used to split values on commas, with optional surrounding whitespace.
2429
+ #
2430
+ # pkg:gem/protocol-http#lib/protocol/http/header/split.rb:14
2431
+ Protocol::HTTP::Header::Split::COMMA = T.let(T.unsafe(nil), Regexp)
2432
+
2433
+ # The `te` header indicates the transfer encodings the client is willing to accept. AKA `accept-transfer-encoding`. How we ended up with `te` instead of `accept-transfer-encoding` is a mystery lost to time.
2434
+ #
2435
+ # The `te` header allows a client to indicate which transfer encodings it can handle, and in what order of preference using quality factors.
2436
+ #
2437
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:16
2438
+ class Protocol::HTTP::Header::TE < ::Protocol::HTTP::Header::Split
2439
+ # Adds one or more comma-separated values to the TE header. The values are converted to lowercase for normalization.
2440
+ #
2441
+ # @parameter value [String] a raw header value containing one or more values separated by commas.
2442
+ #
2443
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:99
2444
+ def <<(value); end
2445
+
2446
+ # @returns [Boolean] whether the `chunked` encoding is accepted.
2447
+ #
2448
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:126
2449
+ def chunked?; end
2450
+
2451
+ # @returns [Boolean] whether the `compress` encoding is accepted.
2452
+ #
2453
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:141
2454
+ def compress?; end
2455
+
2456
+ # @returns [Boolean] whether the `deflate` encoding is accepted.
2457
+ #
2458
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:136
2459
+ def deflate?; end
2460
+
2461
+ # @returns [Boolean] whether the `gzip` encoding is accepted.
2462
+ #
2463
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:131
2464
+ def gzip?; end
2465
+
2466
+ # @returns [Boolean] whether the `identity` encoding is accepted.
2467
+ #
2468
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:146
2469
+ def identity?; end
2470
+
2471
+ # Parse the `te` header and order transfer codings by preference.
2472
+ #
2473
+ # Transfer codings with equal quality factors retain their original relative order.
2474
+ #
2475
+ # @returns [Array(TransferCoding)] the preferred transfer codings.
2476
+ #
2477
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:121
2478
+ def preferred_transfer_codings; end
2479
+
2480
+ # @returns [Boolean] whether trailers are accepted.
2481
+ #
2482
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:151
2483
+ def trailers?; end
2484
+
2485
+ # Parse the `te` header value into a list of transfer codings with quality factors.
2486
+ #
2487
+ # @returns [Array(TransferCoding)] the list of transfer codings and their associated quality factors.
2488
+ #
2489
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:106
2490
+ def transfer_codings; end
2491
+
2492
+ class << self
2493
+ # Coerces a value into a parsed header object.
2494
+ #
2495
+ # @parameter value [String | Array] the value to coerce.
2496
+ # @returns [TE] a parsed header object with normalized values.
2497
+ #
2498
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:87
2499
+ def coerce(value); end
2500
+
2501
+ # Parses a raw header value.
2502
+ #
2503
+ # @parameter value [String] a raw header value containing comma-separated encodings.
2504
+ # @returns [TE] a new instance with normalized (lowercase) encodings.
2505
+ #
2506
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:79
2507
+ def parse(value); end
2508
+
2509
+ # Whether this header is acceptable in HTTP trailers.
2510
+ # TE headers negotiate transfer encodings and must not appear in trailers.
2511
+ # @returns [Boolean] `false`, as TE headers are hop-by-hop and control message framing.
2512
+ #
2513
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:158
2514
+ def trailer?; end
2515
+ end
2516
+ end
2517
+
2518
+ # The `chunked` transfer encoding
2519
+ #
2520
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:29
2521
+ Protocol::HTTP::Header::TE::CHUNKED = T.let(T.unsafe(nil), String)
2522
+
2523
+ # The `compress` transfer encoding
2524
+ #
2525
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:38
2526
+ Protocol::HTTP::Header::TE::COMPRESS = T.let(T.unsafe(nil), String)
2527
+
2528
+ # The `deflate` transfer encoding
2529
+ #
2530
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:35
2531
+ Protocol::HTTP::Header::TE::DEFLATE = T.let(T.unsafe(nil), String)
2532
+
2533
+ # The `gzip` transfer encoding
2534
+ #
2535
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:32
2536
+ Protocol::HTTP::Header::TE::GZIP = T.let(T.unsafe(nil), String)
2537
+
2538
+ # The `identity` transfer encoding
2539
+ #
2540
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:41
2541
+ Protocol::HTTP::Header::TE::IDENTITY = T.let(T.unsafe(nil), String)
2542
+
2543
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:17
2544
+ class Protocol::HTTP::Header::TE::ParseError < ::Protocol::HTTP::InvalidHeaderError; end
2545
+
2546
+ # Quality value pattern (0.0 to 1.0)
2547
+ #
2548
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:23
2549
+ Protocol::HTTP::Header::TE::QVALUE = T.let(T.unsafe(nil), Regexp)
2550
+
2551
+ # Transfer encoding token pattern
2552
+ #
2553
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:20
2554
+ Protocol::HTTP::Header::TE::TOKEN = T.let(T.unsafe(nil), Regexp)
2555
+
2556
+ # The `trailers` pseudo-encoding indicates willingness to accept trailer fields
2557
+ #
2558
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:44
2559
+ Protocol::HTTP::Header::TE::TRAILERS = T.let(T.unsafe(nil), String)
2560
+
2561
+ # Pattern for parsing transfer encoding with optional quality factor
2562
+ #
2563
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:26
2564
+ Protocol::HTTP::Header::TE::TRANSFER_CODING = T.let(T.unsafe(nil), Regexp)
2565
+
2566
+ # A single transfer coding entry with optional quality factor
2567
+ #
2568
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:47
2569
+ class Protocol::HTTP::Header::TE::TransferCoding < ::Struct
2570
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:59
2571
+ def <=>(other); end
2572
+
2573
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:47
2574
+ def name; end
2575
+
2576
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:47
2577
+ def name=(_); end
2578
+
2579
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:47
2580
+ def q; end
2581
+
2582
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:47
2583
+ def q=(_); end
2584
+
2585
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:51
2586
+ def quality_factor; end
2587
+
2588
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:66
2589
+ def to_s; end
2590
+
2591
+ class << self
2592
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:47
2593
+ def [](*_arg0); end
2594
+
2595
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:47
2596
+ def inspect; end
2597
+
2598
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:47
2599
+ def keyword_init?; end
2600
+
2601
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:47
2602
+ def members; end
2603
+
2604
+ # pkg:gem/protocol-http#lib/protocol/http/header/te.rb:47
2605
+ def new(*_arg0); end
2606
+ end
2607
+ end
2608
+
2609
+ # Represents headers that can contain multiple distinct values separated by commas.
2610
+ #
2611
+ # This isn't a specific header class is a utility for handling headers with comma-separated values, such as `accept`, `cache-control`, and other similar headers. The values are split and stored as an array internally, and serialized back to a comma-separated string when needed.
2612
+ #
2613
+ # pkg:gem/protocol-http#lib/protocol/http/header/trailer.rb:14
2614
+ class Protocol::HTTP::Header::Trailer < ::Protocol::HTTP::Header::Split
2615
+ class << self
2616
+ # Whether this header is acceptable in HTTP trailers.
2617
+ # @returns [Boolean] `false`, as Trailer headers control trailer processing and must appear before the message body.
2618
+ #
2619
+ # pkg:gem/protocol-http#lib/protocol/http/header/trailer.rb:17
2620
+ def trailer?; end
2621
+ end
2622
+ end
2623
+
2624
+ # The `transfer-encoding` header indicates the encoding transformations that have been applied to the message body.
2625
+ #
2626
+ # The `transfer-encoding` header is used to specify the form of encoding used to safely transfer the message body between the sender and receiver.
2627
+ #
2628
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:14
2629
+ class Protocol::HTTP::Header::TransferEncoding < ::Protocol::HTTP::Header::Split
2630
+ # Adds one or more comma-separated values to the transfer encoding header. The values are converted to lowercase for normalization.
2631
+ #
2632
+ # @parameter value [String] a raw header value containing one or more values separated by commas.
2633
+ #
2634
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:54
2635
+ def <<(value); end
2636
+
2637
+ # @returns [Boolean] whether the `chunked` encoding is present.
2638
+ #
2639
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:59
2640
+ def chunked?; end
2641
+
2642
+ # @returns [Boolean] whether the `compress` encoding is present.
2643
+ #
2644
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:74
2645
+ def compress?; end
2646
+
2647
+ # @returns [Boolean] whether the `deflate` encoding is present.
2648
+ #
2649
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:69
2650
+ def deflate?; end
2651
+
2652
+ # @returns [Boolean] whether the `gzip` encoding is present.
2653
+ #
2654
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:64
2655
+ def gzip?; end
2656
+
2657
+ # @returns [Boolean] whether the `identity` encoding is present.
2658
+ #
2659
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:79
2660
+ def identity?; end
2661
+
2662
+ class << self
2663
+ # Coerces a value into a parsed header object.
2664
+ #
2665
+ # @parameter value [String | Array] the value to coerce.
2666
+ # @returns [TransferEncoding] a parsed header object with normalized values.
2667
+ #
2668
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:42
2669
+ def coerce(value); end
2670
+
2671
+ # Parses a raw header value.
2672
+ #
2673
+ # @parameter value [String] a raw header value containing comma-separated encodings.
2674
+ # @returns [TransferEncoding] a new instance with normalized (lowercase) encodings.
2675
+ #
2676
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:34
2677
+ def parse(value); end
2678
+
2679
+ # Whether this header is acceptable in HTTP trailers.
2680
+ # Transfer-Encoding headers control message framing and must not appear in trailers.
2681
+ # @returns [Boolean] `false`, as Transfer-Encoding headers are hop-by-hop and must precede the message body.
2682
+ #
2683
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:86
2684
+ def trailer?; end
2685
+ end
2686
+ end
2687
+
2688
+ # The `chunked` transfer encoding allows a server to send data of unknown length by breaking it into chunks.
2689
+ #
2690
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:16
2691
+ Protocol::HTTP::Header::TransferEncoding::CHUNKED = T.let(T.unsafe(nil), String)
2692
+
2693
+ # The `compress` transfer encoding compresses the message body using the compress algorithm.
2694
+ #
2695
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:25
2696
+ Protocol::HTTP::Header::TransferEncoding::COMPRESS = T.let(T.unsafe(nil), String)
2697
+
2698
+ # The `deflate` transfer encoding compresses the message body using the deflate algorithm.
2699
+ #
2700
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:22
2701
+ Protocol::HTTP::Header::TransferEncoding::DEFLATE = T.let(T.unsafe(nil), String)
2702
+
2703
+ # The `gzip` transfer encoding compresses the message body using the gzip algorithm.
2704
+ #
2705
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:19
2706
+ Protocol::HTTP::Header::TransferEncoding::GZIP = T.let(T.unsafe(nil), String)
2707
+
2708
+ # The `identity` transfer encoding indicates no transformation has been applied.
2709
+ #
2710
+ # pkg:gem/protocol-http#lib/protocol/http/header/transfer_encoding.rb:28
2711
+ Protocol::HTTP::Header::TransferEncoding::IDENTITY = T.let(T.unsafe(nil), String)
2712
+
2713
+ # Represents the `vary` header, which specifies the request headers a server considers when determining the response.
2714
+ #
2715
+ # The `vary` header is used in HTTP responses to indicate which request headers affect the selected response. It allows caches to differentiate stored responses based on specific request headers.
2716
+ #
2717
+ # pkg:gem/protocol-http#lib/protocol/http/header/vary.rb:14
2718
+ class Protocol::HTTP::Header::Vary < ::Protocol::HTTP::Header::Split
2719
+ # Adds one or more comma-separated values to the `vary` header. The values are converted to lowercase for normalization.
2720
+ #
2721
+ # @parameter value [String] a raw header value containing one or more values separated by commas.
2722
+ #
2723
+ # pkg:gem/protocol-http#lib/protocol/http/header/vary.rb:39
2724
+ def <<(value); end
2725
+
2726
+ class << self
2727
+ # Coerces a value into a parsed header object.
2728
+ #
2729
+ # @parameter value [String | Array] the value to coerce.
2730
+ # @returns [Vary] a parsed header object with normalized values.
2731
+ #
2732
+ # pkg:gem/protocol-http#lib/protocol/http/header/vary.rb:27
2733
+ def coerce(value); end
2734
+
2735
+ # Parses a raw header value.
2736
+ #
2737
+ # @parameter value [String] a raw header value containing comma-separated header names.
2738
+ # @returns [Vary] a new instance with normalized (lowercase) header names.
2739
+ #
2740
+ # pkg:gem/protocol-http#lib/protocol/http/header/vary.rb:19
2741
+ def parse(value); end
2742
+ end
2743
+ end
2744
+
2745
+ # Headers are an array of key-value pairs. Some header keys represent multiple values.
2746
+ #
2747
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:42
2748
+ class Protocol::HTTP::Headers
2749
+ # Initialize the headers with the specified fields.
2750
+ #
2751
+ # @parameter fields [Array] An array of `[key, value]` pairs.
2752
+ # @parameter tail [Integer | Nil] The index of the trailer start in the @fields array.
2753
+ #
2754
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:77
2755
+ def initialize(fields = T.unsafe(nil), tail = T.unsafe(nil), indexed: T.unsafe(nil), policy: T.unsafe(nil)); end
2756
+
2757
+ # Compare this object to another object. May depend on the order of the fields.
2758
+ #
2759
+ # @returns [Boolean] Whether the other object is equal to this one.
2760
+ #
2761
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:504
2762
+ def ==(other); end
2763
+
2764
+ # Get the value of the specified header key.
2765
+ #
2766
+ # @parameter key [String] The header key.
2767
+ # @returns [String | Array | Object] The header value.
2768
+ #
2769
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:319
2770
+ def [](key); end
2771
+
2772
+ # Set the specified header key to the specified value, replacing any existing values.
2773
+ #
2774
+ # The value can be a String or a coercable value.
2775
+ #
2776
+ # @parameter key [String] the header key.
2777
+ # @parameter value [String | Array] the header value to assign.
2778
+ #
2779
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:287
2780
+ def []=(key, value); end
2781
+
2782
+ # Add the specified header key value pair.
2783
+ #
2784
+ # @parameter key [String] the header key.
2785
+ # @parameter value [String] the header value to assign.
2786
+ # @parameter trailer [Boolean] whether this header is being added as a trailer.
2787
+ #
2788
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:254
2789
+ def add(key, value, trailer: T.unsafe(nil)); end
2790
+
2791
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:492
2792
+ def as_json; end
2793
+
2794
+ # Clear all headers.
2795
+ #
2796
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:113
2797
+ def clear; end
2798
+
2799
+ # Delete all header values for the given key, and return the merged value.
2800
+ #
2801
+ # @parameter key [String] The header key.
2802
+ # @returns [String | Array | Object] The merged header value.
2803
+ #
2804
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:422
2805
+ def delete(key); end
2806
+
2807
+ # Enumerate all header keys and values.
2808
+ #
2809
+ # @yields {|key, value| ...}
2810
+ # @parameter key [String] The header key.
2811
+ # @parameter value [String] The raw header value.
2812
+ #
2813
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:216
2814
+ def each(&block); end
2815
+
2816
+ # @returns [Boolean] Whether the headers are empty.
2817
+ #
2818
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:207
2819
+ def empty?; end
2820
+
2821
+ # Extract the specified keys from the headers.
2822
+ #
2823
+ # @parameter keys [Array] The keys to extract.
2824
+ #
2825
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:235
2826
+ def extract(keys); end
2827
+
2828
+ # @attribute [Array] An array of `[key, value]` pairs.
2829
+ #
2830
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:135
2831
+ def fields; end
2832
+
2833
+ # Flatten trailer into the headers, returning a new instance of {Headers}.
2834
+ #
2835
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:130
2836
+ def flatten; end
2837
+
2838
+ # Flatten trailer into the headers, in-place.
2839
+ #
2840
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:120
2841
+ def flatten!; end
2842
+
2843
+ # Freeze the headers, and ensure the indexed hash is generated.
2844
+ #
2845
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:194
2846
+ def freeze; end
2847
+
2848
+ # Enumerate all the headers in the header, if there are any.
2849
+ #
2850
+ # @yields {|key, value| ...} The header key and value.
2851
+ # @parameter key [String] The header key.
2852
+ # @parameter value [String] The raw header value.
2853
+ #
2854
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:170
2855
+ def header(&block); end
2856
+
2857
+ # @returns [Boolean] Whether the headers include the specified key.
2858
+ #
2859
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:221
2860
+ def include?(key); end
2861
+
2862
+ # Inspect the headers.
2863
+ #
2864
+ # @returns [String] A string representation of the headers.
2865
+ #
2866
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:497
2867
+ def inspect; end
2868
+
2869
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:225
2870
+ def key?(key); end
2871
+
2872
+ # @returns [Array] All the keys of the headers.
2873
+ #
2874
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:228
2875
+ def keys; end
2876
+
2877
+ # Merge the headers into a new instance of {Headers}.
2878
+ #
2879
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:333
2880
+ def merge(headers); end
2881
+
2882
+ # Merge the headers into this instance.
2883
+ #
2884
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:324
2885
+ def merge!(headers); end
2886
+
2887
+ # @attribute [Hash] The policy for the headers.
2888
+ #
2889
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:90
2890
+ def policy; end
2891
+
2892
+ # Set the policy for the headers.
2893
+ #
2894
+ # The policy is used to determine how headers are merged and normalized. For example, if a header is specified multiple times, the policy will determine how the values are merged.
2895
+ #
2896
+ # @parameter policy [Hash] The policy for the headers.
2897
+ #
2898
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:97
2899
+ def policy=(policy); end
2900
+
2901
+ # Set the specified header key to the specified value, replacing any existing header keys with the same name.
2902
+ #
2903
+ # @parameter key [String] the header key to replace.
2904
+ # @parameter value [String] the header value to assign.
2905
+ #
2906
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:276
2907
+ def set(key, value); end
2908
+
2909
+ # @attribute [Integer | Nil] The index where trailers begin.
2910
+ #
2911
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:138
2912
+ def tail; end
2913
+
2914
+ # @returns [Array] The fields of the headers.
2915
+ #
2916
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:141
2917
+ def to_a; end
2918
+
2919
+ # Compute a hash table of headers, where the keys are normalized to lower case and the values are normalized according to the policy for that header.
2920
+ #
2921
+ # This will enforce policy rules, such as merging multiple headers into arrays, or raising errors for duplicate headers.
2922
+ #
2923
+ # @returns [Hash] A hash table of `{key, value}` pairs.
2924
+ #
2925
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:477
2926
+ def to_h; end
2927
+
2928
+ # Enumerate all headers in the trailer, if there are any.
2929
+ #
2930
+ # @yields {|key, value| ...} The header key and value.
2931
+ # @parameter key [String] The header key.
2932
+ # @parameter value [String] The raw header value.
2933
+ #
2934
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:185
2935
+ def trailer(&block); end
2936
+
2937
+ # Record the current headers, and prepare to add trailers.
2938
+ #
2939
+ # This method is typically used after headers are sent to capture any additional headers which should then be sent as trailers.
2940
+ #
2941
+ # A sender that intends to generate one or more trailer fields in a message should generate a trailer header field in the header section of that message to indicate which fields might be present in the trailers.
2942
+ #
2943
+ # @parameter names [Array] The trailer header names which will be added later.
2944
+ # @yields {|name, value| ...} the trailing headers if a block is given.
2945
+ # @returns An enumerator which is suitable for iterating over trailers.
2946
+ #
2947
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:159
2948
+ def trailer!(&block); end
2949
+
2950
+ # @returns [Boolean] Whether there are any trailers.
2951
+ #
2952
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:146
2953
+ def trailer?; end
2954
+
2955
+ protected
2956
+
2957
+ # Merge the value into the hash according to the policy for the given key.
2958
+ #
2959
+ # @parameter hash [Hash] The hash to merge into.
2960
+ # @parameter key [String] The header key.
2961
+ # @parameter value [String] The raw header value.
2962
+ #
2963
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:456
2964
+ def merge_into(hash, key, value); end
2965
+
2966
+ private
2967
+
2968
+ # Initialize a copy of the headers.
2969
+ #
2970
+ # @parameter other [Headers] The headers to copy.
2971
+ #
2972
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:105
2973
+ def initialize_dup(other); end
2974
+
2975
+ class << self
2976
+ # Construct an instance from a headers Array or Hash. No-op if already an instance of `Headers`. If the underlying array is frozen, it will be duped.
2977
+ #
2978
+ # @return [Headers] an instance of headers.
2979
+ #
2980
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:51
2981
+ def [](headers); end
2982
+ end
2983
+ end
2984
+
2985
+ # Used for merging objects into a sequential list of headers. Normalizes header keys and values.
2986
+ #
2987
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:516
2988
+ class Protocol::HTTP::Headers::Merged
2989
+ include ::Enumerable
2990
+
2991
+ # Construct a merged list of headers.
2992
+ #
2993
+ # @parameter *all [Array] An array of all headers to merge.
2994
+ #
2995
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:522
2996
+ def initialize(*all); end
2997
+
2998
+ # Add a new set of headers to the merged list.
2999
+ #
3000
+ # @parameter headers [Headers | Array | Hash] A list of headers to add.
3001
+ #
3002
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:544
3003
+ def <<(headers); end
3004
+
3005
+ # Clear the references to all headers.
3006
+ #
3007
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:537
3008
+ def clear; end
3009
+
3010
+ # Enumerate all headers in the merged list.
3011
+ #
3012
+ # @yields {|key, value| ...} The header key and value.
3013
+ # @parameter key [String] The header key (lower case).
3014
+ # @parameter value [String] The header value.
3015
+ #
3016
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:555
3017
+ def each(&block); end
3018
+
3019
+ # @returns [Array] A list of all headers, in the order they were added, as `[key, value]` pairs.
3020
+ #
3021
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:527
3022
+ def fields; end
3023
+
3024
+ # @returns [Headers] A new instance of {Headers} containing all the merged headers.
3025
+ #
3026
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:532
3027
+ def flatten; end
3028
+ end
3029
+
3030
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:44
3031
+ Protocol::HTTP::Headers::Multiple = Protocol::HTTP::Header::Multiple
3032
+
3033
+ # The policy for various headers, including how they are merged and normalized.
3034
+ #
3035
+ # A policy may be `false` to indicate that the header may only be specified once and is a simple string.
3036
+ #
3037
+ # Otherwise, the policy is a class which implements the header normalization logic, including `parse` and `coerce` class methods.
3038
+ #
3039
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:342
3040
+ Protocol::HTTP::Headers::POLICY = T.let(T.unsafe(nil), Hash)
3041
+
3042
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:43
3043
+ Protocol::HTTP::Headers::Split = Protocol::HTTP::Header::Split
3044
+
3045
+ # pkg:gem/protocol-http#lib/protocol/http/headers.rb:46
3046
+ Protocol::HTTP::Headers::TRAILER = T.let(T.unsafe(nil), String)
3047
+
3048
+ # Raised when an HTTP header is malformed or invalid. When raised while processing an incoming request, it may be treated as a bad request.
3049
+ #
3050
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:30
3051
+ class Protocol::HTTP::InvalidHeaderError < ::Protocol::HTTP::Error
3052
+ include ::Protocol::HTTP::BadRequest
3053
+ end
3054
+
3055
+ # Raised when an invalid trailer header is encountered in headers.
3056
+ #
3057
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:67
3058
+ class Protocol::HTTP::InvalidTrailerError < ::Protocol::HTTP::InvalidHeaderError
3059
+ # @parameter key [String] The trailer key that is invalid.
3060
+ #
3061
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:69
3062
+ def initialize(key); end
3063
+
3064
+ # @attribute [String] key The trailer key that is invalid.
3065
+ #
3066
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:74
3067
+ def key; end
3068
+ end
3069
+
3070
+ # Provides a convenient interface for commonly supported HTTP methods.
3071
+ #
3072
+ #
3073
+ # These methods are defined in this module using lower case names. They are for convenience only and you should not overload those methods.
3074
+ #
3075
+ # See <https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods> for more details.
3076
+ #
3077
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:26
3078
+ class Protocol::HTTP::Methods
3079
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:82
3080
+ def connect(*arguments, **options); end
3081
+
3082
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:82
3083
+ def delete(*arguments, **options); end
3084
+
3085
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:82
3086
+ def get(*arguments, **options); end
3087
+
3088
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:82
3089
+ def head(*arguments, **options); end
3090
+
3091
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:82
3092
+ def options(*arguments, **options); end
3093
+
3094
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:82
3095
+ def patch(*arguments, **options); end
3096
+
3097
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:82
3098
+ def post(*arguments, **options); end
3099
+
3100
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:82
3101
+ def put(*arguments, **options); end
3102
+
3103
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:82
3104
+ def query(*arguments, **options); end
3105
+
3106
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:82
3107
+ def trace(*arguments, **options); end
3108
+
3109
+ class << self
3110
+ # Enumerate all HTTP methods.
3111
+ # @yields {|name, value| ...}
3112
+ # @parameter name [Symbol] The name of the method, e.g. `:GET`.
3113
+ # @parameter value [String] The value of the method, e.g. `"GET"`.
3114
+ #
3115
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:73
3116
+ def each; end
3117
+
3118
+ # Check if the given name is a valid HTTP method, according to this module.
3119
+ #
3120
+ # Note that this method only knows about the methods defined in this module, however there are many other methods defined in different specifications.
3121
+ #
3122
+ # @returns [Boolean] True if the name is a valid HTTP method.
3123
+ #
3124
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:62
3125
+ def valid?(name); end
3126
+ end
3127
+ end
3128
+
3129
+ # The CONNECT method establishes a tunnel to the server identified by the target resource.
3130
+ #
3131
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:43
3132
+ Protocol::HTTP::Methods::CONNECT = T.let(T.unsafe(nil), String)
3133
+
3134
+ # The DELETE method deletes the specified resource.
3135
+ #
3136
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:40
3137
+ Protocol::HTTP::Methods::DELETE = T.let(T.unsafe(nil), String)
3138
+
3139
+ # The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
3140
+ #
3141
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:28
3142
+ Protocol::HTTP::Methods::GET = T.let(T.unsafe(nil), String)
3143
+
3144
+ # The HEAD method asks for a response identical to a GET request, but without the response body.
3145
+ #
3146
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:31
3147
+ Protocol::HTTP::Methods::HEAD = T.let(T.unsafe(nil), String)
3148
+
3149
+ # The OPTIONS method describes the communication options for the target resource.
3150
+ #
3151
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:46
3152
+ Protocol::HTTP::Methods::OPTIONS = T.let(T.unsafe(nil), String)
3153
+
3154
+ # The PATCH method applies partial modifications to a resource.
3155
+ #
3156
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:52
3157
+ Protocol::HTTP::Methods::PATCH = T.let(T.unsafe(nil), String)
3158
+
3159
+ # The POST method submits an entity to the specified resource, often causing a change in state or side effects on the server.
3160
+ #
3161
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:34
3162
+ Protocol::HTTP::Methods::POST = T.let(T.unsafe(nil), String)
3163
+
3164
+ # The PUT method replaces all current representations of the target resource with the request payload.
3165
+ #
3166
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:37
3167
+ Protocol::HTTP::Methods::PUT = T.let(T.unsafe(nil), String)
3168
+
3169
+ # The QUERY method performs a read-only, idempotent query using a request body.
3170
+ #
3171
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:55
3172
+ Protocol::HTTP::Methods::QUERY = T.let(T.unsafe(nil), String)
3173
+
3174
+ # The TRACE method performs a message loop-back test along the path to the target resource.
3175
+ #
3176
+ # pkg:gem/protocol-http#lib/protocol/http/methods.rb:49
3177
+ Protocol::HTTP::Methods::TRACE = T.let(T.unsafe(nil), String)
3178
+
3179
+ # The middleware interface provides a convenient wrapper for implementing HTTP middleware.
3180
+ #
3181
+ # A middleware instance generally needs to respond to two methods:
3182
+ #
3183
+ # - `call(request)` -> `response`
3184
+ # - `close()`
3185
+ #
3186
+ # The call method is called for each request. The close method is called when the server is shutting down.
3187
+ #
3188
+ # You do not need to use the Middleware class to implement middleware. You can implement the interface directly.
3189
+ #
3190
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:23
3191
+ class Protocol::HTTP::Middleware < ::Protocol::HTTP::Methods
3192
+ # Initialize the middleware with the given delegate.
3193
+ #
3194
+ # @parameter delegate [Object] The delegate object. A delegate is used for passing along requests that are not handled by *this* middleware.
3195
+ #
3196
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:39
3197
+ def initialize(delegate); end
3198
+
3199
+ # Call the middleware with the given request. Invokes the call method on the delegate.
3200
+ #
3201
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:52
3202
+ def call(request); end
3203
+
3204
+ # Close the middleware. Invokes the close method on the delegate.
3205
+ #
3206
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:47
3207
+ def close; end
3208
+
3209
+ # @attribute [Object] The delegate object that is used for passing along requests that are not handled by *this* middleware.
3210
+ #
3211
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:44
3212
+ def delegate; end
3213
+
3214
+ class << self
3215
+ # Convert a block to a middleware delegate.
3216
+ #
3217
+ # @parameter block [Proc] The block to convert to a middleware delegate.
3218
+ # @returns [Middleware] The middleware delegate.
3219
+ #
3220
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:28
3221
+ def for(&block); end
3222
+ end
3223
+ end
3224
+
3225
+ # A simple middleware that always returns "Hello World!".
3226
+ #
3227
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:87
3228
+ module Protocol::HTTP::Middleware::HelloWorld
3229
+ class << self
3230
+ # Call the middleware with the given request.
3231
+ #
3232
+ # @parameter request [Request] The request object.
3233
+ # @returns [Response] The response object, whihc always contains "Hello World!".
3234
+ #
3235
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:96
3236
+ def call(request); end
3237
+
3238
+ # Close the middleware - idempotent no-op.
3239
+ #
3240
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:89
3241
+ def close; end
3242
+ end
3243
+ end
3244
+
3245
+ # A simple middleware that always returns a 404 response.
3246
+ #
3247
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:72
3248
+ module Protocol::HTTP::Middleware::NotFound
3249
+ class << self
3250
+ # Call the middleware with the given request, always returning a 404 response. This middleware is useful as a default.
3251
+ #
3252
+ # @parameter request [Request] The request object.
3253
+ # @returns [Response] The response object, which always contains a 404 status code.
3254
+ #
3255
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:81
3256
+ def call(request); end
3257
+
3258
+ # Close the middleware - idempotent no-op.
3259
+ #
3260
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:74
3261
+ def close; end
3262
+ end
3263
+ end
3264
+
3265
+ # A simple middleware that always returns a 200 response.
3266
+ #
3267
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:57
3268
+ module Protocol::HTTP::Middleware::Okay
3269
+ class << self
3270
+ # Call the middleware with the given request, always returning a 200 response.
3271
+ #
3272
+ # @parameter request [Request] The request object.
3273
+ # @returns [Response] The response object, which always contains a 200 status code.
3274
+ #
3275
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:66
3276
+ def call(request); end
3277
+
3278
+ # Close the middleware - idempotent no-op.
3279
+ #
3280
+ # pkg:gem/protocol-http#lib/protocol/http/middleware.rb:59
3281
+ def close; end
3282
+ end
3283
+ end
3284
+
3285
+ # Provide a well defined, cached representation of a peer (address).
3286
+ #
3287
+ # pkg:gem/protocol-http#lib/protocol/http/peer.rb:9
3288
+ class Protocol::HTTP::Peer
3289
+ # Initialize the peer with the given address.
3290
+ #
3291
+ # @parameter address [Addrinfo] The remote address of the peer.
3292
+ #
3293
+ # pkg:gem/protocol-http#lib/protocol/http/peer.rb:22
3294
+ def initialize(address); end
3295
+
3296
+ # @attribute [Addrinfo] The remote address of the peer.
3297
+ #
3298
+ # pkg:gem/protocol-http#lib/protocol/http/peer.rb:31
3299
+ def address; end
3300
+
3301
+ # @attribute [String] The IP address of the peer, if available.
3302
+ #
3303
+ # pkg:gem/protocol-http#lib/protocol/http/peer.rb:34
3304
+ def ip_address; end
3305
+
3306
+ # pkg:gem/protocol-http#lib/protocol/http/peer.rb:36
3307
+ def remote_address; end
3308
+
3309
+ class << self
3310
+ # Create a new peer object for the given IO object, using the remote address if available.
3311
+ #
3312
+ # @returns [Peer | Nil] The peer object, or nil if the remote address is not available.
3313
+ #
3314
+ # pkg:gem/protocol-http#lib/protocol/http/peer.rb:13
3315
+ def for(io); end
3316
+ end
3317
+ end
3318
+
3319
+ # pkg:gem/protocol-http#lib/protocol/http/quoted_string.rb:11
3320
+ Protocol::HTTP::QUOTED_STRING = T.let(T.unsafe(nil), Regexp)
3321
+
3322
+ # https://tools.ietf.org/html/rfc7231#section-5.3.1
3323
+ #
3324
+ # pkg:gem/protocol-http#lib/protocol/http/quoted_string.rb:14
3325
+ Protocol::HTTP::QVALUE = T.let(T.unsafe(nil), Regexp)
3326
+
3327
+ # Handling of HTTP quoted strings.
3328
+ #
3329
+ # pkg:gem/protocol-http#lib/protocol/http/quoted_string.rb:17
3330
+ module Protocol::HTTP::QuotedString
3331
+ class << self
3332
+ # Quote a string for HTTP header values if required.
3333
+ #
3334
+ # @raises [ArgumentError] if the value contains invalid characters like control characters or newlines.
3335
+ #
3336
+ # pkg:gem/protocol-http#lib/protocol/http/quoted_string.rb:37
3337
+ def quote(value, force = T.unsafe(nil)); end
3338
+
3339
+ # Unquote a "quoted-string" value according to <https://tools.ietf.org/html/rfc7230#section-3.2.6>. It should already match the QUOTED_STRING pattern above by the parser.
3340
+ #
3341
+ # pkg:gem/protocol-http#lib/protocol/http/quoted_string.rb:19
3342
+ def unquote(value, normalize_whitespace = T.unsafe(nil)); end
3343
+ end
3344
+ end
3345
+
3346
+ # pkg:gem/protocol-http#lib/protocol/http/quoted_string.rb:32
3347
+ Protocol::HTTP::QuotedString::QUOTES_REQUIRED = T.let(T.unsafe(nil), Regexp)
3348
+
3349
+ # Raised when an HTTP stream or request was refused before any processing occurred.
3350
+ # In the case of requests, it indicates that the request was refused before any processing occurred, and can be safely retried.
3351
+ #
3352
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:14
3353
+ class Protocol::HTTP::RefusedError < ::Protocol::HTTP::Error; end
3354
+
3355
+ # Raised when the remote endpoint fails while processing an HTTP stream or request.
3356
+ # This error does not indicate whether application processing occurred. Where available, the protocol-specific error should be attached as the cause.
3357
+ #
3358
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:19
3359
+ class Protocol::HTTP::RemoteError < ::Protocol::HTTP::Error; end
3360
+
3361
+ # Represents an HTTP request which can be used both server and client-side.
3362
+ #
3363
+ # ~~~ ruby
3364
+ # require 'protocol/http'
3365
+ #
3366
+ # # Long form:
3367
+ # Protocol::HTTP::Request.new("http", "example.com", "GET", "/index.html", "HTTP/1.1", Protocol::HTTP::Headers[["accept", "text/html"]])
3368
+ #
3369
+ # # Short form:
3370
+ # Protocol::HTTP::Request["GET", "/index.html", {"accept" => "text/html"}]
3371
+ # ~~~
3372
+ #
3373
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:25
3374
+ class Protocol::HTTP::Request
3375
+ include ::Protocol::HTTP::Body::Reader
3376
+
3377
+ # Initialize the request.
3378
+ #
3379
+ # @parameter scheme [String | Nil] The request scheme, usually `"http"` or `"https"`.
3380
+ # @parameter authority [String | Nil] The request authority, usually a hostname and port number, e.g. `"example.com:80"`.
3381
+ # @parameter method [String | Nil] The request method, usually one of `"GET"`, `"HEAD"`, `"POST"`, `"PUT"`, `"DELETE"`, `"CONNECT"` or `"OPTIONS"`, etc.
3382
+ # @parameter path [String | Nil] The request path, usually a path and query string, e.g. `"/index.html"`, `"/search?q=hello"`, etc.
3383
+ # @parameter version [String | Nil] The request version, usually `"http/1.0"`, `"http/1.1"`, `"h2"`, or `"h3"`.
3384
+ # @parameter headers [Headers] The request headers, usually containing metadata associated with the request such as the `"user-agent"`, `"accept"` (content type), `"accept-language"`, etc.
3385
+ # @parameter body [Body::Readable] The request body.
3386
+ # @parameter protocol [String | Array(String) | Nil] The request protocol, usually empty, but occasionally `"websocket"` or `"webtransport"`.
3387
+ # @parameter interim_response [Proc] A callback which is called when an interim response is received.
3388
+ #
3389
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:39
3390
+ def initialize(scheme = T.unsafe(nil), authority = T.unsafe(nil), method = T.unsafe(nil), path = T.unsafe(nil), version = T.unsafe(nil), headers = T.unsafe(nil), body = T.unsafe(nil), protocol = T.unsafe(nil), interim_response = T.unsafe(nil)); end
3391
+
3392
+ # Convert the request to a hash, suitable for serialization.
3393
+ #
3394
+ # @returns [Hash] The request as a hash.
3395
+ #
3396
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:181
3397
+ def as_json(*, **, &); end
3398
+
3399
+ # @attribute [String] the request authority, usually a hostname and port number, e.g. `"example.com:80"`.
3400
+ #
3401
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:55
3402
+ def authority; end
3403
+
3404
+ # @attribute [String] the request authority, usually a hostname and port number, e.g. `"example.com:80"`.
3405
+ #
3406
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:55
3407
+ def authority=(_arg0); end
3408
+
3409
+ # @attribute [Body::Readable] the request body. It should only be read once (it may not be idempotent).
3410
+ #
3411
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:70
3412
+ def body; end
3413
+
3414
+ # @attribute [Body::Readable] the request body. It should only be read once (it may not be idempotent).
3415
+ #
3416
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:70
3417
+ def body=(_arg0); end
3418
+
3419
+ # Send the request to the given connection.
3420
+ #
3421
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:86
3422
+ def call(connection); end
3423
+
3424
+ # Whether this is a CONNECT request: typically used to establish a tunnel.
3425
+ #
3426
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:117
3427
+ def connect?; end
3428
+
3429
+ # Whether this is a HEAD request: no body is expected in the response.
3430
+ #
3431
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:112
3432
+ def head?; end
3433
+
3434
+ # @attribute [Headers] the request headers, usually containing metadata associated with the request such as the `"user-agent"`, `"accept"` (content type), `"accept-language"`, etc.
3435
+ #
3436
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:67
3437
+ def headers; end
3438
+
3439
+ # @attribute [Headers] the request headers, usually containing metadata associated with the request such as the `"user-agent"`, `"accept"` (content type), `"accept-language"`, etc.
3440
+ #
3441
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:67
3442
+ def headers=(_arg0); end
3443
+
3444
+ # Whether the request can be replayed without side-effects.
3445
+ #
3446
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:136
3447
+ def idempotent?; end
3448
+
3449
+ # @attribute [Proc] a callback which is called when an interim response is received.
3450
+ #
3451
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:76
3452
+ def interim_response; end
3453
+
3454
+ # @attribute [Proc] a callback which is called when an interim response is received.
3455
+ #
3456
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:76
3457
+ def interim_response=(_arg0); end
3458
+
3459
+ # @attribute [String] the request method, usually one of `"GET"`, `"HEAD"`, `"POST"`, `"PUT"`, `"DELETE"`, `"CONNECT"` or `"OPTIONS"`, etc.
3460
+ #
3461
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:58
3462
+ def method; end
3463
+
3464
+ # @attribute [String] the request method, usually one of `"GET"`, `"HEAD"`, `"POST"`, `"PUT"`, `"DELETE"`, `"CONNECT"` or `"OPTIONS"`, etc.
3465
+ #
3466
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:58
3467
+ def method=(_arg0); end
3468
+
3469
+ # Register a callback to be called when an interim response is received.
3470
+ #
3471
+ # @yields {|status, headers| ...} The callback to be called when an interim response is received.
3472
+ # @parameter status [Integer] The HTTP status code, e.g. `100`, `101`, etc.
3473
+ # @parameter headers [Hash] The headers, e.g. `{"link" => "</style.css>; rel=stylesheet"}`, etc.
3474
+ #
3475
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:100
3476
+ def on_interim_response(&block); end
3477
+
3478
+ # @attribute [String] the request path, usually a path and query string, e.g. `"/index.html"`, `"/search?q=hello"`, however it can be any [valid request target](https://www.rfc-editor.org/rfc/rfc9110#target.resource).
3479
+ #
3480
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:61
3481
+ def path; end
3482
+
3483
+ # @attribute [String] the request path, usually a path and query string, e.g. `"/index.html"`, `"/search?q=hello"`, however it can be any [valid request target](https://www.rfc-editor.org/rfc/rfc9110#target.resource).
3484
+ #
3485
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:61
3486
+ def path=(_arg0); end
3487
+
3488
+ # A request that is generated by a server, may choose to include the peer (address) associated with the request. It should be implemented by a sub-class.
3489
+ #
3490
+ # @returns [Peer | Nil] The peer (address) associated with the request.
3491
+ #
3492
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:81
3493
+ def peer; end
3494
+
3495
+ # @attribute [String | Array(String) | Nil] the request protocol, usually empty, but occasionally `"websocket"` or `"webtransport"`. In HTTP/1, it is used to request a connection upgrade, and in HTTP/2 it is used to indicate a specfic protocol for the stream.
3496
+ #
3497
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:73
3498
+ def protocol; end
3499
+
3500
+ # @attribute [String | Array(String) | Nil] the request protocol, usually empty, but occasionally `"websocket"` or `"webtransport"`. In HTTP/1, it is used to request a connection upgrade, and in HTTP/2 it is used to indicate a specfic protocol for the stream.
3501
+ #
3502
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:73
3503
+ def protocol=(_arg0); end
3504
+
3505
+ # Prepare the request body to be sent again, if it is safe to retry.
3506
+ # @returns [Boolean] Whether the request was prepared for retry.
3507
+ #
3508
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:169
3509
+ def retry!; end
3510
+
3511
+ # Rewind the request body so it can be sent again.
3512
+ # @returns [Boolean] Whether the request body was rewound.
3513
+ #
3514
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:158
3515
+ def rewind!; end
3516
+
3517
+ # @attribute [String] the request scheme, usually `"http"` or `"https"`.
3518
+ #
3519
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:52
3520
+ def scheme; end
3521
+
3522
+ # @attribute [String] the request scheme, usually `"http"` or `"https"`.
3523
+ #
3524
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:52
3525
+ def scheme=(_arg0); end
3526
+
3527
+ # Send an interim response back to the origin of this request, if possible.
3528
+ #
3529
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:91
3530
+ def send_interim_response(status, headers); end
3531
+
3532
+ # Convert the request to JSON.
3533
+ #
3534
+ # @returns [String] The request as JSON.
3535
+ #
3536
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:197
3537
+ def to_json(*, **, &); end
3538
+
3539
+ # Summarize the request as a string.
3540
+ #
3541
+ # @returns [String] The request as a string.
3542
+ #
3543
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:204
3544
+ def to_s; end
3545
+
3546
+ # @attribute [String] the request version, usually `"http/1.0"`, `"http/1.1"`, `"h2"`, or `"h3"`.
3547
+ #
3548
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:64
3549
+ def version; end
3550
+
3551
+ # @attribute [String] the request version, usually `"http/1.0"`, `"http/1.1"`, `"h2"`, or `"h3"`.
3552
+ #
3553
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:64
3554
+ def version=(_arg0); end
3555
+
3556
+ class << self
3557
+ # A short-cut method which exposes the main request variables that you'd typically care about.
3558
+ #
3559
+ # @parameter method [String] The HTTP method, e.g. `"GET"`, `"POST"`, etc.
3560
+ # @parameter path [String] The path, e.g. `"/index.html"`, `"/search?q=hello"`, etc.
3561
+ # @parameter headers [Hash] The headers, e.g. `{"accept" => "text/html"}`, etc.
3562
+ # @parameter body [String | Array(String) | Body::Readable] The body, e.g. `"Hello, World!"`, etc. See {Body::Buffered.wrap} for more information about .
3563
+ #
3564
+ # pkg:gem/protocol-http#lib/protocol/http/request.rb:127
3565
+ def [](method, path = T.unsafe(nil), _headers = T.unsafe(nil), _body = T.unsafe(nil), scheme: T.unsafe(nil), authority: T.unsafe(nil), headers: T.unsafe(nil), body: T.unsafe(nil), protocol: T.unsafe(nil), interim_response: T.unsafe(nil)); end
3566
+ end
3567
+ end
3568
+
3569
+ # @deprecated Use {RefusedError} instead.
3570
+ #
3571
+ # pkg:gem/protocol-http#lib/protocol/http/error.rb:23
3572
+ Protocol::HTTP::RequestRefusedError = Protocol::HTTP::RefusedError
3573
+
3574
+ # Represents an HTTP response which can be used both server and client-side.
3575
+ #
3576
+ # ~~~ ruby
3577
+ # require 'protocol/http'
3578
+ #
3579
+ # # Long form:
3580
+ # Protocol::HTTP::Response.new("http/1.1", 200, Protocol::HTTP::Headers[["content-type", "text/html"]], Protocol::HTTP::Body::Buffered.wrap("Hello, World!"))
3581
+ #
3582
+ # # Short form:
3583
+ # Protocol::HTTP::Response[200, {"content-type" => "text/html"}, ["Hello, World!"]]
3584
+ # ~~~
3585
+ #
3586
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:23
3587
+ class Protocol::HTTP::Response
3588
+ include ::Protocol::HTTP::Body::Reader
3589
+
3590
+ # Create a new response.
3591
+ #
3592
+ # @parameter version [String | Nil] The HTTP version, e.g. `"HTTP/1.1"`. If `nil`, the version may be provided by the server sending the response.
3593
+ # @parameter status [Integer] The HTTP status code, e.g. `200`, `404`, etc.
3594
+ # @parameter headers [Hash] The headers, e.g. `{"content-type" => "text/html"}`, etc.
3595
+ # @parameter body [Body::Readable] The body, e.g. `"Hello, World!"`, etc.
3596
+ # @parameter protocol [String | Array(String)] The protocol, e.g. `"websocket"`, etc.
3597
+ #
3598
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:33
3599
+ def initialize(version = T.unsafe(nil), status = T.unsafe(nil), headers = T.unsafe(nil), body = T.unsafe(nil), protocol = T.unsafe(nil)); end
3600
+
3601
+ # Convert the response to a hash suitable for serialization.
3602
+ #
3603
+ # @returns [Hash] The response as a hash.
3604
+ #
3605
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:158
3606
+ def as_json(*, **, &); end
3607
+
3608
+ # Whether the status is 400 (bad request).
3609
+ #
3610
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:120
3611
+ def bad_request?; end
3612
+
3613
+ # @attribute [Body::Readable] The body, e.g. `"Hello, World!"`, etc.
3614
+ #
3615
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:51
3616
+ def body; end
3617
+
3618
+ # @attribute [Body::Readable] The body, e.g. `"Hello, World!"`, etc.
3619
+ #
3620
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:51
3621
+ def body=(_arg0); end
3622
+
3623
+ # Whether the status is 100 (continue).
3624
+ #
3625
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:69
3626
+ def continue?; end
3627
+
3628
+ # Whether the status is considered a failure.
3629
+ #
3630
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:115
3631
+ def failure?; end
3632
+
3633
+ # Whether the status is considered final. Note that 101 is considered final.
3634
+ #
3635
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:79
3636
+ def final?; end
3637
+
3638
+ # @attribute [Hash] The headers, e.g. `{"content-type" => "text/html"}`, etc.
3639
+ #
3640
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:48
3641
+ def headers; end
3642
+
3643
+ # @attribute [Hash] The headers, e.g. `{"content-type" => "text/html"}`, etc.
3644
+ #
3645
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:48
3646
+ def headers=(_arg0); end
3647
+
3648
+ # Whether the response is considered a hijack: the connection has been taken over by the application and the server should not send any more data.
3649
+ #
3650
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:64
3651
+ def hijack?; end
3652
+
3653
+ # Whether the status is considered informational.
3654
+ #
3655
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:74
3656
+ def informational?; end
3657
+
3658
+ # Whether the status is 500 (internal server error).
3659
+ #
3660
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:125
3661
+ def internal_server_error?; end
3662
+
3663
+ # Whether the status is 304 (not modified).
3664
+ #
3665
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:105
3666
+ def not_modified?; end
3667
+
3668
+ # Whether the status is 200 (ok).
3669
+ #
3670
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:85
3671
+ def ok?; end
3672
+
3673
+ # Whether the status is 206 (partial content).
3674
+ #
3675
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:95
3676
+ def partial?; end
3677
+
3678
+ # A response that is generated by a client, may choose to include the peer (address) associated with the response. It should be implemented by a sub-class.
3679
+ #
3680
+ # @returns [Peer | Nil] The peer (address) associated with the response.
3681
+ #
3682
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:59
3683
+ def peer; end
3684
+
3685
+ # Whether the status is 307 (temporary redirect) and should preserve the method of the request when following the redirect.
3686
+ #
3687
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:110
3688
+ def preserve_method?; end
3689
+
3690
+ # @attribute [String | Array(String) | Nil] The protocol, e.g. `"websocket"`, etc.
3691
+ #
3692
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:54
3693
+ def protocol; end
3694
+
3695
+ # @attribute [String | Array(String) | Nil] The protocol, e.g. `"websocket"`, etc.
3696
+ #
3697
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:54
3698
+ def protocol=(_arg0); end
3699
+
3700
+ # Whether the status is considered a redirection.
3701
+ #
3702
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:100
3703
+ def redirection?; end
3704
+
3705
+ # @deprecated Use {#internal_server_error?} instead.
3706
+ #
3707
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:130
3708
+ def server_failure?; end
3709
+
3710
+ # @attribute [Integer] The HTTP status code, e.g. `200`, `404`, etc.
3711
+ #
3712
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:45
3713
+ def status; end
3714
+
3715
+ # @attribute [Integer] The HTTP status code, e.g. `200`, `404`, etc.
3716
+ #
3717
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:45
3718
+ def status=(_arg0); end
3719
+
3720
+ # Whether the status is considered successful.
3721
+ #
3722
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:90
3723
+ def success?; end
3724
+
3725
+ # Implicit conversion to an array.
3726
+ #
3727
+ # @returns [Array] The response as an array, e.g. `[status, headers, body]`.
3728
+ #
3729
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:185
3730
+ def to_ary; end
3731
+
3732
+ # Convert the response to JSON.
3733
+ #
3734
+ # @returns [String] The response as JSON.
3735
+ #
3736
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:171
3737
+ def to_json(*, **, &); end
3738
+
3739
+ # Summarise the response as a string.
3740
+ #
3741
+ # @returns [String] The response as a string.
3742
+ #
3743
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:178
3744
+ def to_s; end
3745
+
3746
+ # @attribute [String | Nil] The HTTP version, usually one of `"HTTP/1.1"`, `"HTTP/2"`, etc.
3747
+ #
3748
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:42
3749
+ def version; end
3750
+
3751
+ # @attribute [String | Nil] The HTTP version, usually one of `"HTTP/1.1"`, `"HTTP/2"`, etc.
3752
+ #
3753
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:42
3754
+ def version=(_arg0); end
3755
+
3756
+ class << self
3757
+ # A short-cut method which exposes the main response variables that you'd typically care about. It follows the same order as the `Rack` response tuple, but also includes the protocol.
3758
+ #
3759
+ # ~~~ ruby
3760
+ # Response[200, {"content-type" => "text/html"}, ["Hello, World!"]]
3761
+ # ~~~
3762
+ #
3763
+ # @parameter status [Integer] The HTTP status code, e.g. `200`, `404`, etc.
3764
+ # @parameter headers [Hash] The headers, e.g. `{"content-type" => "text/html"}`, etc.
3765
+ # @parameter body [String | Array(String) | Body::Readable] The body, e.g. `"Hello, World!"`, etc. See {Body::Buffered.wrap} for more information about .
3766
+ #
3767
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:141
3768
+ def [](status, _headers = T.unsafe(nil), _body = T.unsafe(nil), headers: T.unsafe(nil), body: T.unsafe(nil), protocol: T.unsafe(nil)); end
3769
+
3770
+ # Create a response for the given exception.
3771
+ #
3772
+ # @parameter exception [Exception] The exception to generate the response for.
3773
+ #
3774
+ # pkg:gem/protocol-http#lib/protocol/http/response.rb:151
3775
+ def for_exception(exception); end
3776
+ end
3777
+ end
3778
+
3779
+ # HTTP status codes and their human-readable descriptions.
3780
+ #
3781
+ # pkg:gem/protocol-http#lib/protocol/http/status.rb:9
3782
+ module Protocol::HTTP::Status
3783
+ class << self
3784
+ # Look up the human-readable description for a status code.
3785
+ # @parameter code [Integer] The HTTP status code.
3786
+ # @returns [String | Nil] The standard description, if known.
3787
+ #
3788
+ # pkg:gem/protocol-http#lib/protocol/http/status.rb:84
3789
+ def description(code); end
3790
+ end
3791
+ end
3792
+
3793
+ # Human-readable descriptions for registered and conventional HTTP status codes.
3794
+ #
3795
+ # pkg:gem/protocol-http#lib/protocol/http/status.rb:11
3796
+ Protocol::HTTP::Status::DESCRIPTIONS = T.let(T.unsafe(nil), Hash)
3797
+
3798
+ # According to https://tools.ietf.org/html/rfc7231#appendix-C
3799
+ #
3800
+ # pkg:gem/protocol-http#lib/protocol/http/quoted_string.rb:9
3801
+ Protocol::HTTP::TOKEN = T.let(T.unsafe(nil), Regexp)