File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -124,10 +124,6 @@ def parent=(stream)
124
124
@dependency . parent = stream . dependency
125
125
end
126
126
127
- # The stream is being closed because the connection is being closed.
128
- def close ( error = nil )
129
- end
130
-
131
127
def maximum_frame_size
132
128
@connection . available_frame_size
133
129
end
@@ -144,6 +140,15 @@ def closed?
144
140
@state == :closed
145
141
end
146
142
143
+ # Transition directly to closed state. Do not pass go, do not collect $200.
144
+ # This method should only be used by `Connection#close`.
145
+ def close ( error = nil )
146
+ unless closed?
147
+ @state = :closed
148
+ self . closed ( error )
149
+ end
150
+ end
151
+
147
152
def send_headers?
148
153
@state == :idle or @state == :reserved_local or @state == :open or @state == :half_closed_remote
149
154
end
@@ -228,16 +233,26 @@ def send_data(*arguments, **options)
228
233
end
229
234
end
230
235
236
+ # The stream has been opened.
237
+ def opened ( error = nil )
238
+ end
239
+
231
240
def open!
232
241
if @state == :idle
233
242
@state = :open
234
243
else
235
244
raise ProtocolError , "Cannot open stream in state: #{ @state } "
236
245
end
237
246
247
+ self . opened
248
+
238
249
return self
239
250
end
240
251
252
+ # The stream has been closed. If closed due to a stream reset, the error will be set.
253
+ def closed ( error = nil )
254
+ end
255
+
241
256
# Transition the stream into the closed state.
242
257
# @param error_code [Integer] the error code if the stream was closed due to a stream reset.
243
258
def close! ( error_code = nil )
@@ -248,7 +263,7 @@ def close!(error_code = nil)
248
263
error = StreamError . new ( "Stream closed!" , error_code )
249
264
end
250
265
251
- self . close ( error )
266
+ self . closed ( error )
252
267
253
268
return self
254
269
end
You can’t perform that action at this time.
0 commit comments