set the host part of the URI
as the argument with brackets for IPv6 addresses.
This method is same as URI::Generic#host=
except the argument can be bare IPv6 address.
u = URI("http://foo/bar") p u.to_s #=> "http://foo/bar" u.hostname = "::1" p u.to_s #=> "http://[::1]/bar"
If the argument seems IPv6 address, it is wrapped by brackets.
v
String
public setter for the port component v
. (with validation)
see also URI::Generic.check_port
require 'uri' uri = URI.parse("http://my.example.com") uri.port = 8080 # => 8080 uri #=> #<URI::HTTP:0x000000008e89e8 URL:http://my.example.com:8080>
Checks if URI
is relative
Returns normalized URI
.
require 'uri' URI("HTTP://my.EXAMPLE.com").normalize #=> #<URI::HTTP http://my.example.com/>
Normalization here means:
scheme and host are converted to lowercase,
an empty path component is set to “/”.
Destructive version of normalize
Constructs String from URI
setter for to v
Constructs String from URI
Starts the CGI
process with the given environment env
and standard input and output stdin
and stdout
.
Sets the cookie expiration to the time t
. The expiration time may be a false value to disable expiration or a Time
or HTTP format time string to set the expiration date.
Retrieves the expiration time as a Time
The cookie string suitable for use in an HTTP header
The host this request is for
The port this request is for
Sets the response’s status to the status
code
The HTTP version as show in the HTTP request and response. For example, “1.1”
Shortcut for logging an ERROR
message
Will the logger output ERROR
messages?
Formats arg
for the logger
If arg
is an Exception
, it will format the error message and the back trace.
If arg
responds to to_str, it will return it.
Otherwise it will return arg
.inspect.
A SimpleServer
only yields when you start it
Performs the standard operations for daemonizing a process. Runs a block, if given.
Adds listeners from address
and port
to the server. See WEBrick::Utils::create_listeners
for details.
Starts the server and runs the block
for each connection. This method does not return until the server is stopped from a signal handler or another thread using stop
or shutdown
.
If the block raises a subclass of StandardError
the exception is logged and ignored. If an IOError
or Errno::EBADF exception is raised the exception is ignored. If an Exception
subclass is raised the exception is logged and re-raised which stops the server.
To completely shut down a server call shutdown
from ensure:
server = WEBrick::GenericServer.new # or WEBrick::HTTPServer.new begin server.start ensure server.shutdown end
Converts the contents of the database to an in-memory Hash
, then calls Hash#reject
with the specified code block, returning a new Hash
.
Replaces the contents of the database with the contents of the specified object. Takes any object which implements the each_pair
method, including Hash
and DBM
objects.