protocol-http1 0.20.0 → 0.21.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: b49dc6301aa7d4aafb183cd1bea576bda5681e9d911245398c8c0c68ca38b1cc
4
- data.tar.gz: b819f86f731d8e68391994e709318460a9c50b64fece83f398868a443faa3a72
3
+ metadata.gz: 66ce05a20db2c35943a45feab35afe95bf530ce562030741984025defb1f0b40
4
+ data.tar.gz: e3066206a22ad274cc28ac13369d330cff0b5bee1641d79c113a3b13354f2f82
5
5
  SHA512:
6
- metadata.gz: fc1c721b351c094243953896088405b4f3800662ac9539bc599cf7d989a48623243d8e443cba789df43fa88d857cd1bacee8ae1fc520a1e5a8a4846bf23c4276
7
- data.tar.gz: c6bcb1f77924b2038167ea8c88cfcfcad9cf7cda91677b09ab2f264ff8f61ef7e782ce0a183144180978fa02a2de5d03bfe3f1f424624e1424efc451724384ba
6
+ metadata.gz: 6bfbfc8977ca31eb293ee61fa43cf042ecf10ee4342c7124880e2bda32b1d966fed74bf0ad02a083d8b3e52a0112482be04da3388e4b9424ec112ef8ddb4bee0
7
+ data.tar.gz: 204d66b3b7b57d3706248d05551cd29ccc50e824d34a4d0173cc90eb8266133abd5d6398cdc7811afb73d5605ca4b4a0107cbfb24679beff0e285616b9354307
checksums.yaml.gz.sig CHANGED
Binary file
@@ -45,7 +45,7 @@ module Protocol
45
45
  length, _extensions = read_line.split(";", 2)
46
46
 
47
47
  unless length =~ VALID_CHUNK_LENGTH
48
- raise BadRequest, "Invalid chunk length: #{length.dump}"
48
+ raise BadRequest, "Invalid chunk length: #{length.inspect}"
49
49
  end
50
50
 
51
51
  # It is possible this line contains chunk extension, so we use `to_i` to only consider the initial integral part:
@@ -93,7 +93,7 @@ module Protocol
93
93
  if match = line.match(HEADER)
94
94
  @headers.add(match[1], match[2])
95
95
  else
96
- raise BadHeader, "Could not parse header: #{line.dump}"
96
+ raise BadHeader, "Could not parse header: #{line.inspect}"
97
97
  end
98
98
  end
99
99
  end
@@ -240,7 +240,7 @@ module Protocol
240
240
  if match = line.match(HEADER)
241
241
  fields << [match[1], match[2]]
242
242
  else
243
- raise BadHeader, "Could not parse header: #{line.dump}"
243
+ raise BadHeader, "Could not parse header: #{line.inspect}"
244
244
  end
245
245
  end
246
246
 
@@ -423,6 +423,7 @@ module Protocol
423
423
  end
424
424
 
425
425
  def read_remainder_body
426
+ @persistent = false
426
427
  Body::Remainder.new(@stream)
427
428
  end
428
429
 
@@ -434,6 +435,12 @@ module Protocol
434
435
  read_remainder_body
435
436
  end
436
437
 
438
+ def read_upgrade_body
439
+ # When you have an incoming upgrade request body, we must be extremely careful not to start reading it until the upgrade has been confirmed, otherwise if the upgrade was rejected and we started forwarding the incoming request body, it would desynchronize the connection (potential security issue).
440
+ # We mitigate this issue by setting @persistent to false, which will prevent the connection from being reused, even if the upgrade fails (potential performance issue).
441
+ read_remainder_body
442
+ end
443
+
437
444
  HEAD = "HEAD"
438
445
  CONNECT = "CONNECT"
439
446
 
@@ -444,7 +451,7 @@ module Protocol
444
451
  if content_length =~ VALID_CONTENT_LENGTH
445
452
  yield Integer(content_length, 10)
446
453
  else
447
- raise BadRequest, "Invalid content length: #{content_length.dump}"
454
+ raise BadRequest, "Invalid content length: #{content_length.inspect}"
448
455
  end
449
456
  end
450
457
  end
@@ -469,6 +476,10 @@ module Protocol
469
476
  return nil
470
477
  end
471
478
 
479
+ if status == 101
480
+ return read_upgrade_body
481
+ end
482
+
472
483
  if (status >= 100 and status < 200) or status == 204 or status == 304
473
484
  return nil
474
485
  end
@@ -495,6 +506,11 @@ module Protocol
495
506
  return read_tunnel_body
496
507
  end
497
508
 
509
+ # A successful upgrade response implies that the connection will become a tunnel immediately after the empty line that concludes the header fields.
510
+ if headers[UPGRADE]
511
+ return read_upgrade_body
512
+ end
513
+
498
514
  # 6. If this is a request message and none of the above are true, then
499
515
  # the message body length is zero (no message body is present).
500
516
  return read_body(headers)
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module HTTP1
8
- VERSION = "0.20.0"
8
+ VERSION = "0.21.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.20.0
4
+ version: 0.21.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-08-26 00:00:00.000000000 Z
45
+ date: 2024-09-02 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