Server class
A Web server.
When its run method is called, it listens for HTTP requests on the bindPort on its bindAddress, and responds to them with HTTP responses.
Each HTTP request is processed through the pipelines, which is a List
of
ServerPipeline objects. A ServerPipeline
contains a sequence of rules (consisting of a pattern and a handler). If
the request matches the pattern, the corresponding handler is invoked. If
the handler returns a result it is used for the HTTP response, and
subsequent handlers and pipelines are not examined. But if the pipeline has
no matches or the matches do not return a result, then the next pipeline is
examined. If after the request has been through all the pipelines without
producing a result, a NotFoundException is thrown.
If an exception is thrown during processing (either by the application's callbacks or by the package's code) the exception handlers will be invoked. Normally, an application will set the server's exceptionHandler.
It is also possible to set exception handlers on each pipeline, to handle exceptions raised within that pipeline. If there is no pipeline exception handler, or it cannot handle the exception, the exception handler on the server will be invoked.
The urlMaxSize and postMaxSize define limits on the valid requests which can be processed. These are set to reasonable finite values to prevent some types of errors and denial-of-service attacks. Their values can be changed if the application needs to handle large HTTP requests.
A typical application will only have one instance of this class. But it is possible to create multiple instances of this class for an application to process HTTP requests from multiple ports/interfaces.
Constructors
Properties
- basePath ↔ String
-
The base path under which all patterns are under. [...]
read / write
- bindAddress ↔ InternetAddress
-
Bind address for the server. [...]
read / write
- bindPort ↔ int
-
Port number for the server. [...]
read / write
- exceptionHandler ↔ ExceptionHandler
-
Server level exception/error handler. [...]
read / write
- id ↔ String
-
Identity of the server. [...]
read / write
- isSecure → bool
-
Indicates if the Web server is running secured HTTPS or unsecured HTTP. [...]
read-only
- numSessions → int
-
Number of active sessions.
read-only
-
pipelines
→ List<
ServerPipeline> -
The handler pipeline. [...]
final
- postMaxSize ↔ int
-
Maximum size of POST contents before it is rejected. [...]
read / write
- requestCreator ↔ RequestCreator
-
Function used to create a Request object for each HTTP request. [...]
read / write
- requestFactory ↔ RequestCreator
-
Use requestCreator instead. [...]
read / write
- sessionCookieForceSecure ↔ bool
-
Force the use of secure cookies for the session cookie. [...]
read / write
- sessionCookieName ↔ String
-
The name of the cookie used to track sessions. [...]
read / write
- sessionExpiry ↔ Duration
-
The default expiry time for sessions in this server. [...]
read / write
- sessionParamName ↔ String
-
The name of the URL query parameter used to track sessions (if cookies
are not used). [...]
read / write
-
sessions
→ Iterable<
Session> -
All active sessions [...]
read-only
- urlMaxSize ↔ int
-
Maximum size of a URL path and query before it is rejected. [...]
read / write
- v6Only ↔ bool
-
Indicates how a bindAddress value of
InternetAddress.anyIPv6
treats IPv4 addresses. [...]read / write - hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
run(
{String privateKeyFilename, String certificateName, String certChainFilename }) → Future< int> - Starts the Web server. [...]
-
simulate(
Request req) → Future< SimulatedResponse> - Simulate the processing of a HTTP request. [...]
-
stop(
{bool force: false }) → Future - Stops the Web server. [...]
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited