protocol-http1 0.26.0 → 0.27.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 868c9501fb3b9a49db11985bb2807cdbfe9ed6c5337c0e01fabd5f7f360874e0
4
- data.tar.gz: 91a076094374bbdd0b42938e7d6dcaaf8cd24170d21da0043be63e4ebe719ffb
3
+ metadata.gz: 88bedd2de9b6357ee48174d2a984d5f8cdc391311b0ac13cbd21c4e398d2076b
4
+ data.tar.gz: 4e631b85f63d21cd5dc4e93a49b014301d4faf42c8f0c04bc4341045a34cffe7
5
5
  SHA512:
6
- metadata.gz: 14e0e59673d857dd2e37bcf8b9b1ef607d9490445c13bd515530aabd04dd75f93eca1055a3168384b0fe47f3197494b6be544e3e4f767d55456a4808e090e738
7
- data.tar.gz: ea52162a1762c35cf7ea76630c51f589f52385baf5819b7a4010cec1a341e0ec153ffba1970bead118ebf7e309e63d400a2bc7e81195cd8c1d547c924c4c83d9
6
+ metadata.gz: 751ca8414f97b9e6a35daf7350e6e5afb5d59bb3c6be1d740aa78c57a838111c49757b0da43f2875899b6b94d050fc0d163dd4a9d449f2f8450a6b219b7a07fc
7
+ data.tar.gz: 879adf7b92618c4707459c5498f1a8c5567a01c73c466c371f32488820f54b85b17ab92e1259434bf64d4e7b48dcc92d2a6e70eca273a90094ed87773a22c315
checksums.yaml.gz.sig CHANGED
Binary file
@@ -182,7 +182,8 @@ module Protocol
182
182
  @stream = nil
183
183
  stream.flush
184
184
 
185
- self.closed!
185
+ @state = :hijacked
186
+ self.closed
186
187
 
187
188
  return stream
188
189
  end
@@ -203,13 +204,20 @@ module Protocol
203
204
  stream.close
204
205
  end
205
206
 
206
- self.closed!(error)
207
+ unless closed?
208
+ @state = :closed
209
+ self.closed(error)
210
+ end
207
211
  end
208
212
 
209
213
  def open!
210
- raise ProtocolError, "Cannot write request in #{@state}!" unless @state == :idle
214
+ unless @state == :idle
215
+ raise ProtocolError, "Cannot open connection in state: #{@state}!"
216
+ end
211
217
 
212
218
  @state = :open
219
+
220
+ return self
213
221
  end
214
222
 
215
223
  def write_request(authority, method, path, version, headers)
@@ -223,7 +231,7 @@ module Protocol
223
231
 
224
232
  def write_response(version, status, headers, reason = Reason::DESCRIPTIONS[status])
225
233
  unless @state == :open or @state == :half_closed_remote
226
- raise ProtocolError, "Cannot write response in #{@state}!"
234
+ raise ProtocolError, "Cannot write response in state: #{@state}!"
227
235
  end
228
236
 
229
237
  # Safari WebSockets break if no reason is given:
@@ -234,7 +242,7 @@ module Protocol
234
242
 
235
243
  def write_interim_response(version, status, headers, reason = Reason::DESCRIPTIONS[status])
236
244
  unless @state == :open or @state == :half_closed_remote
237
- raise ProtocolError, "Cannot write interim response in #{@state}!"
245
+ raise ProtocolError, "Cannot write interim response in state: #{@state}!"
238
246
  end
239
247
 
240
248
  @stream.write("#{version} #{status} #{reason}\r\n")
@@ -328,7 +336,7 @@ module Protocol
328
336
 
329
337
  def read_response(method)
330
338
  unless @state == :open or @state == :half_closed_local
331
- raise ProtocolError, "Cannot read response in #{@state}!"
339
+ raise ProtocolError, "Cannot read response in state: #{@state}!"
332
340
  end
333
341
 
334
342
  version, status, reason = read_response_line
@@ -371,9 +379,9 @@ module Protocol
371
379
  if @state == :open
372
380
  @state = :half_closed_local
373
381
  elsif @state == :half_closed_remote
374
- self.closed!
382
+ self.close!
375
383
  else
376
- raise ProtocolError, "Cannot send end stream in #{@state}!"
384
+ raise ProtocolError, "Cannot send end stream in state: #{@state}!"
377
385
  end
378
386
  end
379
387
 
@@ -525,18 +533,24 @@ module Protocol
525
533
  self.send_end_stream!
526
534
  end
527
535
 
536
+ # The connection (stream) was closed. It may now be in the idle state.
537
+ def closed(error = nil)
538
+ end
539
+
528
540
  # Transition to the closed state.
529
541
  #
530
542
  # If no error occurred, and the connection is persistent, this will immediately transition to the idle state.
531
543
  #
532
544
  # @parameter error [Exxception] the error that caused the connection to close.
533
- def closed!(error = nil)
545
+ def close!(error = nil)
534
546
  if @persistent and !error
535
547
  # If there was no error, and the connection is persistent, we can reuse it:
536
548
  @state = :idle
537
549
  else
538
550
  @state = :closed
539
551
  end
552
+
553
+ self.closed(error)
540
554
  end
541
555
 
542
556
  def write_body(version, body, head = false, trailer = nil)
@@ -574,9 +588,9 @@ module Protocol
574
588
  if @state == :open
575
589
  @state = :half_closed_remote
576
590
  elsif @state == :half_closed_local
577
- self.closed!
591
+ self.close!
578
592
  else
579
- raise ProtocolError, "Cannot receive end stream in #{@state}!"
593
+ raise ProtocolError, "Cannot receive end stream in state: #{@state}!"
580
594
  end
581
595
  end
582
596
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module HTTP1
8
- VERSION = "0.26.0"
8
+ VERSION = "0.27.0"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-http1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.0
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -42,7 +42,7 @@ cert_chain:
42
42
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
43
43
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
44
44
  -----END CERTIFICATE-----
45
- date: 2024-09-23 00:00:00.000000000 Z
45
+ date: 2024-09-24 00:00:00.000000000 Z
46
46
  dependencies:
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: protocol-http
metadata.gz.sig CHANGED
Binary file