shelf_io library

A Shelf adapter for handling HttpRequest objects from dart:io's HttpServer.

One can provide an instance of HttpServer as the requests parameter in serveRequests.

This adapter supports request hijacking; see Request.hijack.

Requests passed to a Handler will contain the Request.context key "shelf.io.connection_info" containing the HttpConnectionInfo object from the underlying HttpRequest.

When creating Response instances for this adapter, you can set the "shelf.io.buffer_output" key in Response.context. If true, (the default), streamed responses will be buffered to improve performance. If false, all chunks will be pushed over the wire as they're received. See HttpResponse.bufferOutput for more information.

Classes

IOServer
A Server backed by a dart:io HttpServer.

Functions

handleRequest(HttpRequest request, Handler handler, {String? poweredByHeader = 'Dart with package:shelf'}) Future<void>
Uses handler to handle request.
serve(Handler handler, Object address, int port, {SecurityContext? securityContext, int? backlog, bool shared = false, String? poweredByHeader = 'Dart with package:shelf'}) Future<HttpServer>
Starts an HttpServer that listens on the specified address and port and sends requests to handler.
serveRequests(Stream<HttpRequest> requests, Handler handler, {String? poweredByHeader = 'Dart with package:shelf'}) → void
Serve a Stream of HttpRequests.