http_multi_server
v3.2.2A dart:io HttpServer wrapper that handles requests from multiple servers.
Package archive: https://pubdev.letsnova.ru/api/archives/http_multi_server/3.2.2.tar.gz
dart pub add http_multi_serverReadme
An implementation of dart:io's HttpServer that wraps multiple servers and
forwards methods to all of them. It's useful for serving the same application on
multiple network interfaces while still having a unified way of controlling the
servers. In particular, it supports serving on both the IPv4 and IPv6 loopback
addresses using HttpMultiServer.loopback.
import 'package:http_multi_server/http_multi_server.dart';
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as shelf_io;
void main() async {
// Both http://127.0.0.1:8080 and http://[::1]:8080 will be bound to the same
// server.
var server = await HttpMultiServer.loopback(8080);
shelf_io.serveRequests(server, (request) {
return shelf.Response.ok("Hello, world!");
});
}
Changelog
3.2.2
- Require Dart 3.2
- Move to
dart-lang/httpmonorepo.
3.2.1
- Populate the pubspec
repositoryfield.
3.2.0
- Honor the
preserveHeaderCaseargument toMultiHeaders.setand.add.
3.1.0
- Add
HttpMultiServer.bindSecureto matchHttpMultiServer.bind.
3.0.1
- Fix an issue where
bindwould bind to theanyIPv6address in unsupported environments.
3.0.0
- Migrate to null safety.
2.2.0
-
Preparation for HttpHeaders change. Update signature of
MultiHeaders.add()andMultiHeaders.set()to match new signature ofHttpHeaders. The parameter is not yet forwarded and will not behave as expected.
2.1.0
- Add
HttpMultiServer.bindstatic which centralizes logic around common local serving scenarios - handling a more flexible 'localhost' and listening on 'any' hostname. - Update SDK constraints to
>=2.1.0 <3.0.0.
2.0.6
- If there is a problem starting a loopback Ipv6 server, don't keep the Ipv4 server open when throwing the exception.
2.0.5
- Update SDK constraints to
>=2.0.0-dev <3.0.0.
2.0.4
- Declare support for
async2.0.0.
2.0.3
- Fix
HttpMultiServer.loopback()and.loopbackSecure()for environments that don't support IPv4.
2.0.2
- Fix a dependency that was incorrectly marked as dev-only.
2.0.1
- Fix most strong mode errors and warnings.
2.0.0
-
Breaking: Change the signature of
HttpMultiServer.loopbackSecure()to match the new Dart 1.13HttpServer.bindSecure()signature. This removes thecertificateNamenamed parameter and adds the requiredcontextparameter and the namedv6Onlyandsharedparameters. -
Added
v6Onlyandsharedparameters toHttpMultiServer.loopback()to matchHttpServer.bind().
1.3.2
-
Eventually stop retrying port allocation if it fails repeatedly.
-
Properly detect socket errors caused by already-in-use addresses.
1.3.1
loopback()andloopbackSecure()recover gracefully if an ephemeral port is requested and the located port isn't available on both IPv4 and IPv6.
1.3.0
- Add support for
HttpServer.autoCompress.
1.2.0
-
Add support for
HttpServer.defaultResponseHeaders.clear. -
Fix
HttpServer.defaultResponseHeaders.removeand.removeAll.
1.1.0
- Add support for
HttpServer.defaultResponseHeaders.
1.0.2
- Remove the workaround for issue 19815.
1.0.1
- Ignore errors from one of the servers if others are still bound. In particular, this works around issue 19815 on some Windows machines where IPv6 failure isn't discovered until we try to connect to the socket.
