Smart HTTP server over dart:io's HttpServer.
This is the only transport adapter of the server layer, and its folder is
the only place of that layer that imports dart:io. It is deliberately
thin: it converts each HttpRequest into a GitHttpRequest without
decoding the path and without decompressing the body, hands it to a
GitSmartHttpHandler, and writes the returned response back.
What the server does
- It passes the request path exactly as received (still percent-encoded) and the request body as a byte stream, so the processing decodes the path and applies the body decoder itself.
- When the handler carries no body decoder, the server supplies
dartIoGzipBodyDecoder, so
gzip-compressed request bodies are read out of the box. - The request body and the response body flow at the same time: the response is written through the HTTP response, which reads the service only as fast as the socket accepts the bytes, while the request body keeps being read at the pace its consumer set. Neither direction waits for the other, and memory stays bounded in both.
- When the response body fails mid-flight, it destroys the connection instead of ending the chunked stream, so the client never mistakes a truncated body for a complete one.
- When the client disconnects, it cancels the response, which releases the service and the git process behind it.
- One connection carries one exchange: the connection closes after the response.
- The concurrency and duration limits are the handler's; the adapter only carries requests and destroys a connection whose response fails.
Authentication
Authentication belongs to the host application. The server receives an
authenticate callback that reads the HttpRequest and returns the
GitPrincipal the host authenticated, or null for an anonymous request.
The server never inspects credentials itself.
Properties
- address → InternetAddress
-
The address the server listens on.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- port → int
-
The port the server listens on; the effective port when bind was
given 0.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
{bool force = false}) → Future< void> - Stops accepting requests and closes the server.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
bind(
{required GitSmartHttpHandler handler, required FutureOr< GitPrincipal?> authenticate(HttpRequest request), InternetAddress? address, int port = 0, }) → Future<DartIoGitHttpServer> -
Binds a server on
addressandport, and starts answering smart HTTP requests withhandler.