Sha256: 152651351bd604c67fdde0d9b11a129c533848f0593bf40acd6ba1eb0ca27529
Contents?: true
Size: 691 Bytes
Versions: 3
Compression:
Stored size: 691 Bytes
Contents
# frozen_string_literal: true require 'bundler/inline' gemfile do gem 'h1p' gem 'polyphony', path: '.' end require 'polyphony' require 'h1p' def handle_client(conn) spin do parser = H1P::Parser.new(conn, :server) while true # assuming persistent connection headers = parser.parse_headers break unless headers parser.read_body unless parser.complete? conn << "HTTP/1.1 200 OK\r\nContent-Length: 14\r\n\r\nHello, world!\n" end rescue H1P::Error puts 'Got invalid request, closing connection...' ensure conn.close end end puts "Serving HTTP on port 1234..." TCPServer.new('0.0.0.0', 1234).accept_loop { |c| handle_client(c) }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
polyphony-0.96 | examples/pipes/http_server.rb |
polyphony-0.95 | examples/pipes/http_server.rb |
polyphony-0.94 | examples/pipes/http_server.rb |