2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2016-01-09 12:23:11 +00:00
|
|
|
# file is based on Twitter::Streaming::Connection, needed to get custom_connection_handle
|
|
|
|
# to close connection after config has changed
|
|
|
|
class Twitter::Streaming::ConnectionCustom < Twitter::Streaming::Connection
|
|
|
|
|
|
|
|
def stream(request, response)
|
|
|
|
client_context = OpenSSL::SSL::SSLContext.new
|
2016-01-15 17:22:57 +00:00
|
|
|
@client = @tcp_socket_class.new(Resolv.getaddress(request.uri.host), request.uri.port)
|
|
|
|
ssl_client = @ssl_socket_class.new(@client, client_context)
|
2016-01-09 12:23:11 +00:00
|
|
|
|
|
|
|
ssl_client.connect
|
|
|
|
request.stream(ssl_client)
|
2020-02-18 19:51:31 +00:00
|
|
|
while body = ssl_client.readpartial(1024) # rubocop:disable Lint/AssignmentInCondition
|
2016-01-09 12:23:11 +00:00
|
|
|
response << body
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def custom_connection_handle
|
|
|
|
@client
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|