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.3'

Class Method Summary collapse

Class Method Details

.run(background: false, **kwargs) {|request, socket| ... } ⇒ Object

Starts the HTTP Server.

Parameters:

  • background (Boolean) (defaults to: false)

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

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments for Net::HTTP::Server::Daemon#initialize.

Options Hash (**kwargs):

  • :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.

  • :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.

Raises:

  • (ArgumentError)

    No handler: value was given.



42
43
44
45
46
47
48
# File 'lib/net/http/server/server.rb', line 42

def Server.run(background: false, **kwargs,&block)
  daemon = Daemon.new(**kwargs,&block)

  daemon.start
  daemon.join unless background
  return daemon
end