http-protocol 0.1.1 → 0.2.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: dc3146b471e66a9c5aa3c96ca8542b8a0c62b9e5db3c5ab345f9631320496b66
4
- data.tar.gz: c1aeb31222c732ed4f7e20cff448b8b6ae0cedc3f6d0fe534084d7d3505131df
3
+ metadata.gz: 8ba0f4a74cb833ca6a7c69171365f88c20bbec3259f772113584925184eaa94d
4
+ data.tar.gz: 26a7e84575e89fb6df648385919c78d83b97eebdc62964f2236760d9014bdcab
5
5
  SHA512:
6
- metadata.gz: b322ec2b8596ea94eb543efe7b4ace32b32eb15111fbff9760b2fdfe3ef1967c1b766e7b8d87bdee968e46fc594cb4ae8df83fc3eb241d9a3f4a180860c11040
7
- data.tar.gz: 3a770b0dc7a42d435cd93823483b6e4d27f80a7d3fb7bd254177f4ea7835d78f107fe4acea2b2959868d4b49cab060e241b813504dce668234d9250a1f6256f9
6
+ metadata.gz: d0e337d55ea940907d52cd94767b2a6a0016a19512b35cbdf8632e96f82ef510d06de7d63e2bafea741d6c37fd0f55966ffcdf3865b1829b107891533b237b4c
7
+ data.tar.gz: 7c9c8dd1cd2684a8036260cbd847d60e1540450467cc871460a6baa63a9f460906d0c3bf3f0e6494ba6e4db5c0e11273bd0b6fbb356eed4128ee3c9181214846
@@ -127,13 +127,18 @@ module HTTP
127
127
 
128
128
  def send_goaway(error_code = 0, message = "")
129
129
  frame = GoawayFrame.new
130
- frame.pack @last_stream_id, error_code, message
130
+ frame.pack @remote_stream_id, error_code, message
131
131
 
132
132
  write_frame(frame)
133
133
 
134
134
  @state = :closed
135
135
  end
136
136
 
137
+ def receive_goaway(frame)
138
+ @state = :closed
139
+ @framer.close
140
+ end
141
+
137
142
  def write_frame(frame)
138
143
  # puts "#{self.class} #{@state} write_frame: #{frame.inspect}"
139
144
  @framer.write_frame(frame)
@@ -260,11 +265,20 @@ module HTTP
260
265
  end
261
266
  end
262
267
 
268
+ def deleted_stream? frame
269
+ frame.stream_id <= @local_stream_id or frame.stream_id <= @remote_stream_id
270
+ end
271
+
263
272
  def receive_priority(frame)
264
273
  if stream = @streams[frame.stream_id]
265
274
  stream.receive_priority(frame)
275
+ elsif deleted_stream? frame
276
+ # ignore
266
277
  else
267
- raise ProtocolError, "Bad stream"
278
+ stream = create_stream(frame.stream_id)
279
+ stream.receive_priority(frame)
280
+
281
+ @streams[frame.stream_id] = stream
268
282
  end
269
283
  end
270
284
 
@@ -273,6 +287,8 @@ module HTTP
273
287
  stream.receive_reset_stream(frame)
274
288
 
275
289
  @streams.delete(stream.id)
290
+ elsif deleted_stream? frame
291
+ # ignore
276
292
  else
277
293
  raise ProtocolError, "Bad stream"
278
294
  end
@@ -283,8 +299,8 @@ module HTTP
283
299
  super
284
300
  elsif stream = @streams[frame.stream_id]
285
301
  stream.receive_window_update(frame)
286
- elsif frame.stream_id <= @local_stream_id or frame.stream_id <= @remote_stream_id
287
- # The stream was closed/deleted, ignore
302
+ elsif deleted_stream? frame
303
+ # ignore
288
304
  else
289
305
  raise ProtocolError, "Cannot update window of non-existant stream: #{frame.stream_id}"
290
306
  end
@@ -60,6 +60,10 @@ module HTTP
60
60
  @buffer = String.new.b
61
61
  end
62
62
 
63
+ def close
64
+ @io.close
65
+ end
66
+
63
67
  def write_connection_preface
64
68
  @io.write(CONNECTION_PREFACE_MAGIC)
65
69
  end
@@ -97,7 +101,12 @@ module HTTP
97
101
  end
98
102
 
99
103
  def read_header
100
- return Frame.parse_header(@io.read(9))
104
+ if buffer = @io.read(9)
105
+ return Frame.parse_header(buffer)
106
+ else
107
+ # TODO: Is this necessary? I thought the IO would throw this.
108
+ raise EOFError
109
+ end
101
110
  end
102
111
  end
103
112
  end
@@ -45,12 +45,6 @@ module HTTP
45
45
 
46
46
  TYPE = 0x1
47
47
 
48
- def initialize(*)
49
- super
50
-
51
- @priority = nil
52
- end
53
-
54
48
  def priority?
55
49
  flag_set?(PRIORITY)
56
50
  end
@@ -122,7 +122,7 @@ module HTTP
122
122
  if send_headers?
123
123
  send_headers(nil, [
124
124
  [':status', status.to_s],
125
- [':reason', reason]
125
+ ['reason', reason]
126
126
  ], END_STREAM)
127
127
  else
128
128
  send_reset_stream(PROTOCOL_ERROR)
@@ -20,6 +20,6 @@
20
20
 
21
21
  module HTTP
22
22
  module Protocol
23
- VERSION = "0.1.1"
23
+ VERSION = "0.2.0"
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.1.1
4
+ version: 0.2.0
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-07-31 00:00:00.000000000 Z
11
+ date: 2018-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-hpack