Sha256: 489ac121994e7b82a653c804f0d53ba4ac9870e3264c1a66b9aa12d2211a0011

Contents?: true

Size: 851 Bytes

Versions: 2

Compression:

Stored size: 851 Bytes

Contents

# frozen_string_literal: true

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

authority = Localhost::Authority.fetch
server_ctx = authority.server_context

resolver = spin_loop do
  name, client = receive
  client << server_ctx
end

server_ctx.servername_cb = proc do |_socket, name|
  resolver << [name, Fiber.current]
  receive
end

opts = {
  reuse_addr:     true,
  dont_linger:    true,
  secure_context: server_ctx
}

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

puts 'Serving HTTPS on port 1234'

# server.accept_loop do |socket|
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

2 entries across 2 versions & 1 rubygems

Version Path
polyphony-0.98 examples/io/https_server_sni_2.rb
polyphony-0.97 examples/io/https_server_sni_2.rb