Sha256: 75a1c42c698c5d120320573bcec2698e90a5f3e7fb95f1bd8caf40af7cb3a97f

Contents?: true

Size: 655 Bytes

Versions: 46

Compression:

Stored size: 655 Bytes

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'polyphony'
require 'localhost/authority'

authority = Localhost::Authority.fetch
opts = {
  reuse_addr:     true,
  dont_linger:    true,
  secure_context: authority.server_context
}

server = Polyphony::Net.tcp_listen('localhost', 1234, opts)

puts 'Serving HTTPS on port 1234'

spin_loop(interval: 1) { STDOUT << '.' }

# server.accept_loop do |socket|
while (socket = server.accept)
  spin do
    while (data = socket.gets("\n", 8192))
      if data.chomp.empty?
        socket << "HTTP/1.1 200 OK\nConnection: close\nContent-Length: 4\n\nfoo\n"
        break
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
polyphony-0.96 examples/io/https_server.rb
polyphony-0.95 examples/io/https_server.rb
polyphony-0.94 examples/io/https_server.rb
polyphony-0.93 examples/io/https_server.rb
polyphony-0.92 examples/io/https_server.rb
polyphony-0.91 examples/io/https_server.rb
polyphony-0.90 examples/io/https_server.rb
polyphony-0.89 examples/io/https_server.rb
polyphony-0.87 examples/io/https_server.rb
polyphony-0.86 examples/io/https_server.rb
polyphony-0.85 examples/io/https_server.rb
polyphony-0.84.1 examples/io/https_server.rb
polyphony-0.84 examples/io/https_server.rb
polyphony-0.83 examples/io/https_server.rb
polyphony-0.82 examples/io/https_server.rb
polyphony-0.81.1 examples/io/https_server.rb
polyphony-0.81 examples/io/https_server.rb
polyphony-0.80 examples/io/https_server.rb
polyphony-0.79 examples/io/https_server.rb
polyphony-0.78 examples/io/https_server.rb