Sha256: 1930637a3429038e15e5a75f40e7b50c5944784e2dda2e6f22cbbdcb56d89eb3
Contents?: true
Size: 872 Bytes
Versions: 6
Compression:
Stored size: 872 Bytes
Contents
require 'http/parser' require 'openssl' require 'resolv' module Twitter module Streaming class Connection def initialize(opts = {}) @tcp_socket_class = opts.fetch(:tcp_socket_class) { TCPSocket } @ssl_socket_class = opts.fetch(:ssl_socket_class) { OpenSSL::SSL::SSLSocket } end attr_reader :tcp_socket_class, :ssl_socket_class def stream(request, response) client_context = OpenSSL::SSL::SSLContext.new client = @tcp_socket_class.new(Resolv.getaddress(request.uri.host), request.uri.port) ssl_client = @ssl_socket_class.new(client, client_context) ssl_client.connect request.stream(ssl_client) while body = ssl_client.readpartial(1024) # rubocop:disable AssignmentInCondition, WhileUntilModifier response << body end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems