http-protocol 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/http/protocol/http2/connection.rb +22 -4
- data/lib/http/protocol/http2/continuation_frame.rb +2 -2
- data/lib/http/protocol/http2/frame.rb +9 -1
- data/lib/http/protocol/http2/framer.rb +3 -2
- data/lib/http/protocol/http2/settings_frame.rb +0 -3
- data/lib/http/protocol/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84fb025f5c2cc394607d0c28b592c8fda12285a8340c0d3eb2a5ec8328aab371
|
4
|
+
data.tar.gz: 98a7233fe2c8e0f706d9738b0845bd86a9edd7e4fadf4335fc30763a3a468927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a436986f8203efcc943a7353acb3a8c9489f5e5576127b913482b684f4d879de6f4b88b05c9b17bd5c981826177be00b7f1f2876a6239ee0a5b7c17763afc84
|
7
|
+
data.tar.gz: 4453a7d3c4cab53a2ba6fdb1db9eb82988157582cd9c01b8aca9dd437d13cd6adfc4b20e1e03065cfc0150c497f67f8a05de3d1706d0ec932519e291227216a2
|
@@ -81,6 +81,12 @@ module HTTP
|
|
81
81
|
@state == :closed
|
82
82
|
end
|
83
83
|
|
84
|
+
def close
|
85
|
+
send_goaway
|
86
|
+
|
87
|
+
@framer.close
|
88
|
+
end
|
89
|
+
|
84
90
|
def encode_headers(headers, buffer = String.new.b)
|
85
91
|
HPACK::Compressor.new(buffer, @encoder).encode(headers)
|
86
92
|
|
@@ -103,8 +109,8 @@ module HTTP
|
|
103
109
|
attr :streams
|
104
110
|
|
105
111
|
def read_frame
|
106
|
-
frame = @framer.read_frame
|
107
|
-
# puts "#{self.class} #{@state} read_frame:
|
112
|
+
frame = @framer.read_frame(@local_settings.maximum_frame_size)
|
113
|
+
# puts "#{self.class} #{@state} read_frame: class=#{frame.class} flags=#{frame.flags} length=#{frame.length}"
|
108
114
|
|
109
115
|
yield frame if block_given?
|
110
116
|
|
@@ -113,6 +119,15 @@ module HTTP
|
|
113
119
|
return frame
|
114
120
|
rescue ProtocolError => error
|
115
121
|
send_goaway(error.code || PROTOCOL_ERROR, error.message)
|
122
|
+
|
123
|
+
raise
|
124
|
+
rescue HTTP::HPACK::CompressionError => error
|
125
|
+
send_goaway(COMPRESSION_ERROR, error.message)
|
126
|
+
|
127
|
+
raise
|
128
|
+
rescue
|
129
|
+
send_goaway(PROTOCOL_ERROR, $!.message)
|
130
|
+
|
116
131
|
raise
|
117
132
|
end
|
118
133
|
|
@@ -136,11 +151,10 @@ module HTTP
|
|
136
151
|
|
137
152
|
def receive_goaway(frame)
|
138
153
|
@state = :closed
|
139
|
-
@framer.close
|
140
154
|
end
|
141
155
|
|
142
156
|
def write_frame(frame)
|
143
|
-
# puts "#{self.class} #{@state} write_frame:
|
157
|
+
# puts "#{self.class} #{@state} write_frame: class=#{frame.class} flags=#{frame.flags} length=#{frame.length}"
|
144
158
|
@framer.write_frame(frame)
|
145
159
|
end
|
146
160
|
|
@@ -246,6 +260,10 @@ module HTTP
|
|
246
260
|
end
|
247
261
|
|
248
262
|
def receive_headers(frame)
|
263
|
+
if frame.stream_id == 0
|
264
|
+
raise ProtocolError, "Cannot receive headers for stream 0!"
|
265
|
+
end
|
266
|
+
|
249
267
|
if stream = @streams[frame.stream_id]
|
250
268
|
stream.receive_headers(frame)
|
251
269
|
|
@@ -34,13 +34,13 @@ module HTTP
|
|
34
34
|
flag_set?(END_HEADERS)
|
35
35
|
end
|
36
36
|
|
37
|
-
def read(io)
|
37
|
+
def read(io, maximum_frame_size)
|
38
38
|
super
|
39
39
|
|
40
40
|
unless end_headers?
|
41
41
|
@continuation = ContinuationFrame.new
|
42
42
|
|
43
|
-
@continuation.read(io)
|
43
|
+
@continuation.read(io, maximum_frame_size)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -29,6 +29,9 @@ module HTTP
|
|
29
29
|
PADDED = 0x8
|
30
30
|
PRIORITY = 0x20
|
31
31
|
|
32
|
+
MAXIMUM_ALLOWED_WINDOW_SIZE = 0x7FFFFFFF
|
33
|
+
MAXIMUM_ALLOWED_FRAME_SIZE = 0xFFFFFF
|
34
|
+
|
32
35
|
class Frame
|
33
36
|
include Comparable
|
34
37
|
|
@@ -156,8 +159,13 @@ module HTTP
|
|
156
159
|
@payload = io.read(@length)
|
157
160
|
end
|
158
161
|
|
159
|
-
def read(io)
|
162
|
+
def read(io, maximum_frame_size = MAXIMUM_ALLOWED_FRAME_SIZE)
|
160
163
|
read_header(io) unless @length
|
164
|
+
|
165
|
+
if @length > maximum_frame_size
|
166
|
+
raise FrameSizeError, "Frame length #{@length} exceeds maximum frame size #{maximum_frame_size}!"
|
167
|
+
end
|
168
|
+
|
161
169
|
read_payload(io)
|
162
170
|
end
|
163
171
|
|
@@ -78,7 +78,7 @@ module HTTP
|
|
78
78
|
return string
|
79
79
|
end
|
80
80
|
|
81
|
-
def read_frame
|
81
|
+
def read_frame(maximum_frame_size = MAXIMUM_ALLOWED_FRAME_SIZE)
|
82
82
|
# Read the header:
|
83
83
|
length, type, flags, stream_id = read_header
|
84
84
|
|
@@ -89,7 +89,7 @@ module HTTP
|
|
89
89
|
frame = klass.new(stream_id, flags, type, length)
|
90
90
|
|
91
91
|
# Read the payload:
|
92
|
-
frame.read(@io)
|
92
|
+
frame.read(@io, maximum_frame_size)
|
93
93
|
|
94
94
|
return frame
|
95
95
|
end
|
@@ -97,6 +97,7 @@ module HTTP
|
|
97
97
|
def write_frame(frame)
|
98
98
|
# puts "framer: write_frame #{frame.inspect}"
|
99
99
|
frame.write(@io)
|
100
|
+
|
100
101
|
@io.flush
|
101
102
|
end
|
102
103
|
|
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.3.
|
4
|
+
version: 0.3.2
|
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-
|
11
|
+
date: 2018-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-hpack
|