Class Server
Defined in: httpserver.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Server(requestHandler)
Encapsulates a simple HTTP server for testing.
|
Field Attributes | Field Name and Description |
---|---|
<inner> |
Method Attributes | Method Name and Description |
---|---|
address()
|
|
host()
return {string} The host:port of this server.
|
|
start(opt_port)
Starts the server on the given port.
|
|
stop()
Stops the server.
|
|
url(opt_pathname)
Formats a URL for this server.
|
Class Detail
Server(requestHandler)
Encapsulates a simple HTTP server for testing. The {@code onrequest}
function should be overridden to define request handling behavior.
- Parameters:
- {function(!http.ServerRequest|!http.ServerResponse)} requestHandler
- The request handler for the server.
Field Detail
<inner>
Host
Method Detail
{Host}
address()
- Throws:
- {Error}
- If the server is not running.
- Returns:
- {Host} This server's host info.
host()
return {string} The host:port of this server.
- Throws:
- {Error}
- If the server is not running.
{!webdriver.promise.Promise.}
start(opt_port)
Starts the server on the given port. If no port, or 0, is provided,
the server will be started on a random port.
- Parameters:
- {number=} opt_port
- The port to start on.
- Returns:
- {!webdriver.promise.Promise.
} A promise that will resolve with the server host when it has fully started.
{!webdriver.promise.Promise}
stop()
Stops the server.
- Returns:
- {!webdriver.promise.Promise} A promise that will resolve when the server has closed all connections.
{string}
url(opt_pathname)
Formats a URL for this server.
- Parameters:
- {string=} opt_pathname
- The desired pathname on the server.
- Throws:
- {Error}
- If the server is not running.
- Returns:
- {string} The formatted URL.