Sha256: d4fb24f076351adb5d17362a1600d6591d7056df20a3fc3b7e50c1aba4e54948

Contents?: true

Size: 476 Bytes

Versions: 3

Compression:

Stored size: 476 Bytes

Contents

require 'openssl'
require 'resolv'

module SimpleStream
  class Connection
    def stream(request, response)
      client_context = OpenSSL::SSL::SSLContext.new
      client = TCPSocket.new(Resolv.getaddress(request.uri.host), request.uri.port)
      ssl_client = OpenSSL::SSL::SSLSocket.new(client, client_context)
      ssl_client.connect
      request.stream(ssl_client)

      while body = ssl_client.readpartial(1024)
        response << body
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simple_stream-0.0.3 lib/simple_stream/connection.rb
simple_stream-0.0.2 lib/simple_stream/connection.rb
simple_stream-0.0.1 lib/simple_stream/connection.rb