http-protocol 0.2.0 → 0.2.1

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: 8ba0f4a74cb833ca6a7c69171365f88c20bbec3259f772113584925184eaa94d
4
- data.tar.gz: 26a7e84575e89fb6df648385919c78d83b97eebdc62964f2236760d9014bdcab
3
+ metadata.gz: 6a0181ccc138681d1fa437bf49e9760a45d841245baffd0da21e604a8eaab309
4
+ data.tar.gz: 64cd9dfba7a97c8b0f22a6e5492a4757d331349bc26fc53f5590442ed393576e
5
5
  SHA512:
6
- metadata.gz: d0e337d55ea940907d52cd94767b2a6a0016a19512b35cbdf8632e96f82ef510d06de7d63e2bafea741d6c37fd0f55966ffcdf3865b1829b107891533b237b4c
7
- data.tar.gz: 7c9c8dd1cd2684a8036260cbd847d60e1540450467cc871460a6baa63a9f460906d0c3bf3f0e6494ba6e4db5c0e11273bd0b6fbb356eed4128ee3c9181214846
6
+ metadata.gz: '02369ca5d469cbc24140bafbd5c1bbd6a0949364139c9c78794ee8e7aa36c55d36937c4f7ea5d60978eb31d9fb539c13f2121ea82aa1bdb45a377e80f73f5254'
7
+ data.tar.gz: 4d3f147a6491b19f5bdc667bf3f5508836c23e1494091775dd550696df2137272cb829cf1a727e28d16a66c942d7dfa76c704a1531f36f2affec0b038b7d56ae
@@ -45,7 +45,7 @@ module HTTP
45
45
  elsif amount >= 0 and amount <= @remote_window.available
46
46
  @remote_window.consume(amount)
47
47
  else
48
- raise FlowControlError, "Trying to send #{frame.inspect}, exceeded window size: #{@remote_window.available}"
48
+ raise FlowControlError, "Trying to send #{frame.length} bytes, exceeded window size: #{@remote_window.available} (#{@remote_window})"
49
49
  end
50
50
  end
51
51
 
@@ -40,28 +40,18 @@ module HTTP
40
40
  flag_set?(PADDED)
41
41
  end
42
42
 
43
- # We will round up frames to the given length:
44
- MODULUS = 0x0F
45
-
46
- def pack(data, modulus: MODULUS, padding_size: nil, maximum_size: nil)
47
- padding_size ||= (MODULUS - data.bytesize) % MODULUS
48
-
49
- if maximum_size
50
- maximum_padding_size = maximum_size - data.bytesize
51
-
52
- if padding_size > maximum_padding_size
53
- padding_size = maximum_padding_size
54
- end
55
- end
56
-
57
- if padding_size > 0
43
+ def pack(data, padding_size: nil, maximum_size: nil)
44
+ if padding_size
58
45
  set_flags(PADDED)
59
46
 
60
47
  buffer = String.new.b
61
48
 
62
49
  buffer << padding_size.chr
63
50
  buffer << data
64
- buffer << "\0" * padding_size
51
+
52
+ if padding_size > 1
53
+ buffer << "\0" * (padding_size - 1)
54
+ end
65
55
 
66
56
  super buffer
67
57
  else
@@ -74,7 +64,7 @@ module HTTP
74
64
  def unpack
75
65
  if padded?
76
66
  padding_size = @payload[0].ord
77
- data_size = @payload.bytesize - 1 - padding_size
67
+ data_size = (@payload.bytesize - 1) - padding_size
78
68
 
79
69
  if data_size < 0
80
70
  raise ProtocolError, "Invalid padding length: #{padding_size}"
@@ -20,6 +20,7 @@
20
20
 
21
21
  require_relative 'frame'
22
22
  require_relative 'padded'
23
+ require_relative 'continuation_frame'
23
24
 
24
25
  module HTTP
25
26
  module Protocol
@@ -60,6 +60,10 @@ module HTTP
60
60
  def limited?
61
61
  @used > (@capacity / 2)
62
62
  end
63
+
64
+ def to_s
65
+ "\#<Window #{@used}/#{@capacity}>"
66
+ end
63
67
  end
64
68
 
65
69
  # The WINDOW_UPDATE frame is used to implement flow control.
@@ -20,6 +20,6 @@
20
20
 
21
21
  module HTTP
22
22
  module Protocol
23
- VERSION = "0.2.0"
23
+ VERSION = "0.2.1"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-protocol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-04 00:00:00.000000000 Z
11
+ date: 2018-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-hpack