You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/async/http/protocol/http1/server.rb
+19-17
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ def initialize(...)
22
22
@ready=Async::Notification.new
23
23
end
24
24
25
-
defclosed!
25
+
defclosed(error=nil)
26
26
super
27
27
28
28
@ready.signal
@@ -38,14 +38,12 @@ def fail_request(status)
38
38
end
39
39
40
40
defnext_request
41
-
# Wait for the connection to become idle before reading the next request:
42
-
unlessidle?
41
+
ifclosed?
42
+
returnnil
43
+
elsif !idle?
43
44
@ready.wait
44
45
end
45
46
46
-
# The default is true.
47
-
returnunless@persistent
48
-
49
47
# Read an incoming request:
50
48
returnunlessrequest=Request.read(self)
51
49
@@ -90,37 +88,41 @@ def each(task: Task.current)
90
88
# We force a 101 response if the protocol is upgraded - HTTP/2 CONNECT will return 200 for success, but this won't be understood by HTTP/1 clients:
91
89
write_response(@version,101,response.headers)
92
90
93
-
stream=write_upgrade_body(protocol)
94
-
95
91
# At this point, the request body is hijacked, so we don't want to call #finish below.
96
92
request=nil
97
93
response=nil
98
94
99
-
# In the case of streaming, `finishable` should wrap a `Remainder` body, which we can safely discard later on.
100
-
body.call(stream)
95
+
ifbody.stream?
96
+
returnbody.call(write_upgrade_body(protocol))
97
+
else
98
+
write_upgrade_body(protocol,body)
99
+
end
101
100
elsifresponse.status == 101
102
101
# This code path is to support legacy behavior where the response status is set to 101, but the protocol is not upgraded. This may not be a valid use case, but it is supported for compatibility. We expect the response headers to contain the `upgrade` header.
0 commit comments