10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/twitter-stream-patch.rb', line 10
def stream(request, response)
client_context = OpenSSL::SSL::SSLContext.new
client = @tcp_socket_class.new(Resolv.getaddress(request.socket_host), request.socket_port)
ssl_client = @ssl_socket_class.new(client, client_context)
ssl_client.connect
request.stream(ssl_client)
loop do
begin
body = ssl_client.read_nonblock(1024)
response << body
rescue IO::WaitReadable
r, _ = IO.select([ssl_client], nil, nil, 90)
if r.nil?
ssl_client.close
raise Twitter::Error::StreamDisconnect
end
retry
end
end
end
|