Module: Net::HTTP::Server

Defined in:
lib/net/http/server/daemon.rb,
lib/net/http/server/parser.rb,
lib/net/http/server/server.rb,
lib/net/http/server/stream.rb,
lib/net/http/server/version.rb,
lib/net/http/server/requests.rb,
lib/net/http/server/responses.rb,
lib/net/http/server/chunked_stream.rb

Defined Under Namespace

Modules: Requests, Responses Classes: ChunkedStream, Daemon, Parser, Stream

Constant Summary collapse

VERSION =

net-http-server version.

'0.2.2'

Class Method Summary collapse

Class Method Details

.run(options = {}) {|request, socket| ... } ⇒ Object

Starts the HTTP Server.

Parameters:

  • options (Hash) (defaults to: {})

    Options for the server.

Options Hash (options):

  • :host (String) — default: DEFAULT_HOST

    The host to run on.

  • :port (String) — default: DEFAULT_PORT

    The port to listen on.

  • :max_connections (Integer) — default: MAX_CONNECTIONS

    The maximum number of simultaneous connections.

  • :background (Boolean) — default: false

    Specifies whether to run the server in the background or foreground.

  • :handler (#call)

    The HTTP Request Handler object.

Yields:

  • (request, socket)

    If a block is given, it will be used to process HTTP Requests.

Yield Parameters:

  • request (Hash{Symbol => String,Array,Hash})

    The HTTP Request.

  • socket (TCPSocket)

    The TCP socket of the client.



39
40
41
42
43
44
45
# File 'lib/net/http/server/server.rb', line 39

def Server.run(options={},&block)
  daemon = Daemon.new(options,&block)

  daemon.start
  daemon.join unless options[:background]
  return daemon
end