lib/async/http/protocol/http1/server.rb in async-http-0.75.0 vs lib/async/http/protocol/http1/server.rb in async-http-0.76.0

- old
+ new

@@ -66,22 +66,34 @@ write_response(@version, 101, response.headers) stream = write_upgrade_body(protocol) # At this point, the request body is hijacked, so we don't want to call #finish below. - request = nil unless request.body + request = nil response = nil # We must return here as no further request processing can be done: return body.call(stream) + elsif response.status == 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. + write_response(@version, response.status, response.headers) + + stream = write_tunnel_body(request.version) + + # Same as above: + request = nil + response = nil + + # We must return here as no further request processing can be done: + return body&.call(stream) else write_response(@version, response.status, response.headers) if request.connect? and response.success? stream = write_tunnel_body(request.version) # Same as above: - request = nil unless request.body + request = nil response = nil # We must return here as no further request processing can be done: return body.call(stream) else