lib/async/http/protocol/http1/response.rb in async-http-0.40.3 vs lib/async/http/protocol/http1/response.rb in async-http-0.41.0
- old
+ new
@@ -23,13 +23,29 @@
module Async
module HTTP
module Protocol
module HTTP1
class Response < Protocol::Response
- def initialize(protocol, request)
- super(*protocol.read_response(request.method))
+ def self.read(connection, request)
+ if parts = connection.read_response(request.method)
+ self.new(connection, *parts)
+ end
+ end
+
+ def initialize(connection, version, status, reason, headers, body)
+ @connection = connection
- @protocol = protocol
+ protocol = connection.upgrade?(headers)
+
+ super(version, status, reason, headers, body, protocol)
+ end
+
+ def hijack?
+ @body.nil?
+ end
+
+ def hijack!
+ @connection.hijack!
end
end
end
end
end