Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge package:http_multi_server #1416

Merged
merged 115 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
816ac38
Add an http_multi_server package.
nex3 Jun 5, 2014
bf3c130
Add a LICENSE file to pkg/http_multi_server.
nex3 Jun 5, 2014
8df4fcf
Swallow errors in subscriptions in http_multi_server..
nex3 Jul 24, 2014
80a11f8
Remove the workaround for issue 19815 in http_multi_server.
nex3 Jul 30, 2014
e034b88
Add dummy implementation of defaultResponseHeaders
sgjesse Aug 12, 2014
e883828
Add support for HttpServer.defaultResponseHeaders to HttpMultiServer.
nex3 Aug 14, 2014
f2beb70
Fix analyzer warnings in http_multi_server.
nex3 Aug 14, 2014
e39fb07
Add HttpServer:autoCompress option, to disable auto gzip compression.
Sep 23, 2014
dfcc4a7
Release http_multi_server 1.3.0.
nex3 Sep 23, 2014
83fbe23
Give http_multi_server a more accurate SDK bound.
nex3 Sep 24, 2014
ab32229
Clean up http_multi_server.
Sep 24, 2014
f479103
Add gitignore, status, and codereview files.
nex3 Dec 17, 2014
7944efc
Update the pubspec's homepage link.
nex3 Dec 17, 2014
4b300ce
Fix the status file to match the package bots' expectations.
nex3 Dec 18, 2014
5cef50d
Properly skip tests in packages directories.
nex3 Dec 19, 2014
6b03e0d
Recover gracefully if a matching port is unavailable.
nex3 Mar 9, 2015
1e13011
Eventually stop retrying port allocation if it fails repeatedly.
nex3 Mar 10, 2015
8098e79
Use OSError.errorCode rather than .errno.
nex3 Mar 10, 2015
c9d513e
Upgrade to the new test package.
nex3 Jul 16, 2015
d230d25
Update loopback constructors to match dart:io.
nex3 Dec 9, 2015
ce0dd31
Get rid of all the library tags.
nex3 Jan 13, 2016
4df9fdf
Fix most strong mode warnings.
nex3 Apr 1, 2016
f09d35a
Properly depend on async.
nex3 Jun 20, 2016
230a641
Work in IPv6-only environments. (dart-lang/http_multi_server#2)
nex3 Oct 25, 2016
3f161f5
Change '127.0.0.1' to 'localhost' to support both IPv4 and IPv6 envs.
keertip Jun 21, 2017
d0507f6
Add travis-ci support
kevmoo Feb 7, 2017
b37ced8
Use the correct name for analysis_options
kevmoo Aug 2, 2017
19903c0
dartfmt
kevmoo Aug 2, 2017
f2df083
Homepage: use https (dart-lang/http_multi_server#4)
kevmoo Aug 2, 2017
c174b74
Remove -dev.infinity in SDK upper constraint
kevmoo Sep 19, 2017
d08c3ca
Declare support for async 2.0.0 (dart-lang/http_multi_server#5)
nex3 Sep 22, 2017
2cd3d63
Update .gitignore to new `dart_tool` pub cache
bcko May 24, 2018
883b045
remove .pub and packages
bcko May 28, 2018
46a6135
Update SDK to version 2.0.0-dev.55.0. (dart-lang/http_multi_server#8)
lrhn Jun 1, 2018
031fd1d
Dart 2 cleanup (dart-lang/http_multi_server#10)
chalin Jul 19, 2018
ef7eba4
Update dev deps to latest
kevmoo Jan 18, 2019
7e75f3c
enable and fix a number of lints
kevmoo Jan 18, 2019
44177a3
Close Ipv4 server when failing to start Ipv6 (dart-lang/http_multi_se…
natebosch Apr 25, 2019
42504c7
Test on oldest supported SDK, bump min SDK to stable release (dart-la…
kevmoo May 15, 2019
f704a00
Enforce override annotations (dart-lang/http_multi_server#14)
natebosch Jun 3, 2019
94bc5bd
Wrap description to stay under 80 chars. (dart-lang/http_multi_server…
natebosch Jun 3, 2019
e0b2b27
Add HttpMultiServer.bind utility (dart-lang/http_multi_server#16)
natebosch Jun 4, 2019
ebbd1af
Merge pull request dart-lang/http_multi_server#6 from bcko/patch-1
mit-mit Jun 19, 2019
7a48a66
Add example; bump pedantic
srawlins Sep 16, 2019
8c5b385
Async/await
srawlins Sep 16, 2019
6b4127d
Bump minimum to 2.1.1, for pedantic
srawlins Sep 16, 2019
c674bb1
Merge pull request dart-lang/http_multi_server#18 from srawlins/pedantic
srawlins Sep 16, 2019
17245f9
Fix newly enforced package:pedantic lints (dart-lang/http_multi_serve…
natebosch Dec 9, 2019
5efb004
Add preserveHeaderCase argument (dart-lang/http_multi_server#22)
natebosch Jan 29, 2020
3fcc0c8
Prepare to publish (dart-lang/http_multi_server#24)
natebosch Jan 31, 2020
4e14640
Drop the publish_to: none (dart-lang/http_multi_server#25)
natebosch Jan 31, 2020
45e5901
Remove unused dart:async import (dart-lang/http_multi_server#28)
MichaelRFairhurst Sep 25, 2020
695c819
Change issue link to https. (dart-lang/http_multi_server#27)
Amitbhave Sep 25, 2020
4ba71c3
Pass a Uri to package:http APIs (dart-lang/http_multi_server#29)
natebosch Dec 9, 2020
e7d065c
Skip test binding to IPv4 without support (dart-lang/http_multi_serve…
natebosch Dec 9, 2020
32e9ac7
Migrate to GitHub Actions (dart-lang/http_multi_server#31)
athomas Feb 1, 2021
d052873
migrate to null safety (dart-lang/http_multi_server#32)
jakemac53 Feb 25, 2021
c3a9371
stable null safety release (dart-lang/http_multi_server#33)
jakemac53 Feb 25, 2021
f4546e6
Update LICENSE
franklinyow Apr 6, 2021
e46998b
Merge pull request dart-lang/http_multi_server#34 from dart-lang/fran…
franklinyow Apr 6, 2021
264d705
Bind to the correct address for
grouma Apr 12, 2021
e421e9c
doc
grouma Apr 12, 2021
dd1814f
fix test
grouma Apr 12, 2021
28d39cc
changelog
grouma Apr 12, 2021
8e8035a
Merge pull request dart-lang/http_multi_server#36 from dart-lang/any
grouma Apr 12, 2021
007b3d3
Add a bindSecure method (dart-lang/http_multi_server#19)
natebosch Apr 12, 2021
bcdc341
Avoid IPv4 when unsupported (dart-lang/http_multi_server#37)
natebosch Apr 30, 2021
ec3b3e4
Add dependabot
kevmoo Jun 5, 2021
d28e78e
Bump dart-lang/setup-dart from 0.3 to 1 (dart-lang/http_multi_server#38)
dependabot[bot] Jun 5, 2021
d2820ed
Forward the preserveHeaderCase argument (dart-lang/http_multi_server#39)
natebosch Feb 2, 2022
8d07869
Drop unnecessary SDK constraint suffix (dart-lang/http_multi_server#40)
natebosch Feb 10, 2022
da60302
Bump actions/checkout from 2 to 3 (dart-lang/http_multi_server#41)
dependabot[bot] Mar 2, 2022
f1a3288
Update pubspec.yaml
devoncarew Apr 29, 2022
106b743
rev to a dev version
devoncarew Apr 29, 2022
2c4a533
Merge pull request dart-lang/http_multi_server#42 from dart-lang/devo…
devoncarew May 2, 2022
b69c6f0
switch to package:lints
devoncarew May 12, 2022
fd17403
Merge pull request dart-lang/http_multi_server#43 from dart-lang/pack…
devoncarew May 18, 2022
2555ef5
3.2.1
devoncarew Jun 15, 2022
f1e619d
Merge pull request dart-lang/http_multi_server#44 from dart-lang/prep…
devoncarew Jun 15, 2022
5f6fbe0
blast_repo fixes (dart-lang/http_multi_server#46)
kevmoo Nov 9, 2022
b6ae63c
Bump actions/checkout from 3.1.0 to 3.2.0 (dart-lang/http_multi_serve…
dependabot[bot] Jan 3, 2023
d415434
Migrate from no-implicit-casts to strict-casts (dart-lang/http_multi_…
srawlins Jan 9, 2023
076ef46
Bump actions/checkout from 3.2.0 to 3.3.0 (dart-lang/http_multi_serve…
dependabot[bot] Feb 1, 2023
8a9583e
Bump dart-lang/setup-dart from 1.3 to 1.4 (dart-lang/http_multi_serve…
dependabot[bot] Feb 1, 2023
ae85c13
Require Dart 2.19, enable and fix new team lints (dart-lang/http_mult…
kevmoo Mar 6, 2023
4e98ab8
Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/http_multi_s…
dependabot[bot] Apr 3, 2023
7e71efb
Bump actions/checkout from 3.3.0 to 3.5.0 (dart-lang/http_multi_serve…
dependabot[bot] Apr 3, 2023
8b5c7ec
Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/http_multi_serve…
dependabot[bot] May 8, 2023
a43a0a4
blast_repo fixes (dart-lang/http_multi_server#55)
devoncarew May 17, 2023
334125d
Bump actions/checkout from 3.5.2 to 3.5.3 (dart-lang/http_multi_serve…
dependabot[bot] Jul 1, 2023
779cbaf
Bump actions/checkout from 3.5.3 to 3.6.0 (dart-lang/http_multi_serve…
dependabot[bot] Sep 1, 2023
e8d5de4
Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (dart-lang/http_multi_s…
dependabot[bot] Oct 1, 2023
9e338f0
Bump actions/checkout from 3.6.0 to 4.1.0 (dart-lang/http_multi_serve…
dependabot[bot] Oct 2, 2023
ff00778
Bump actions/checkout from 4.1.0 to 4.1.1 (dart-lang/http_multi_serve…
dependabot[bot] Nov 1, 2023
2c389f5
Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (dart-lang/http_multi_s…
dependabot[bot] Dec 2, 2023
5a87d97
blast_repo fixes (dart-lang/http_multi_server#62)
kevmoo Jan 24, 2024
f28092d
Update lints, require Dart 3.2 (dart-lang/http_multi_server#63)
kevmoo Jan 24, 2024
fad988c
Bump dart-lang/setup-dart from 1.6.1 to 1.6.2 (dart-lang/http_multi_s…
dependabot[bot] Feb 1, 2024
0e0d661
Bump actions/checkout from 4.1.1 to 4.1.2 (dart-lang/http_multi_serve…
dependabot[bot] Apr 1, 2024
34b47f5
Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (dart-lang/http_multi_s…
dependabot[bot] May 1, 2024
e9ba5c5
Bump actions/checkout from 4.1.2 to 4.1.4 (dart-lang/http_multi_serve…
dependabot[bot] May 2, 2024
a304f32
blast_repo fixes (dart-lang/http_multi_server#68)
devoncarew May 6, 2024
f5bf636
Bump actions/checkout from 4.1.4 to 4.1.5 in the github-actions group…
dependabot[bot] May 6, 2024
74159ad
Bump actions/checkout from 4.1.5 to 4.1.6 in the github-actions group…
dependabot[bot] Jun 1, 2024
a41bcb6
Bump the github-actions group with 2 updates (dart-lang/http_multi_se…
dependabot[bot] Jul 1, 2024
e0e499e
Bump actions/checkout from 4.1.7 to 4.2.0 in the github-actions group…
dependabot[bot] Oct 1, 2024
55feb82
blast_repo fixes (dart-lang/http_multi_server#73)
kevmoo Oct 29, 2024
21d42dd
Bump actions/checkout from 4.2.0 to 4.2.2 in the github-actions group…
dependabot[bot] Nov 1, 2024
2b0b562
Bump dart-lang/setup-dart in the github-actions group (dart-lang/http…
dependabot[bot] Dec 1, 2024
658b4c4
Merge package:http_multi_server into the http monorepo
mosuem Dec 6, 2024
ab30c76
Add issue template and other fixes
mosuem Dec 6, 2024
c5b5f9c
Moving issues
mosuem Dec 6, 2024
cc1efef
Update labeler.yml
devoncarew Dec 6, 2024
19386a7
Update README.md
mosuem Dec 9, 2024
b6a4eeb
Add license to example
mosuem Dec 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/http_multi_server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: "package:http_multi_server"
about: "Create a bug or file a feature request against package:http_multi_server."
labels: "package:http_multi_server"
---
22 changes: 13 additions & 9 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,32 @@

'type-infra':
- changed-files:
- any-glob-to-any-file: '.github/**'
- any-glob-to-any-file: '.github/**'

'package:cronet_http':
- changed-files:
- any-glob-to-any-file: 'pkgs/cronet_http/**'
- any-glob-to-any-file: 'pkgs/cronet_http/**'

'package:cupertino_http':
- changed-files:
- any-glob-to-any-file: 'pkgs/cupertino_http/**'
- any-glob-to-any-file: 'pkgs/cupertino_http/**'

'package:http':
- changed-files:
- any-glob-to-any-file: 'pkgs/http/**'
- any-glob-to-any-file: 'pkgs/http/**'

'package:http2':
- changed-files:
- any-glob-to-any-file: 'pkgs/http2/**'
- any-glob-to-any-file: 'pkgs/http2/**'

'package:http_parser':
'package:http_client_conformance_tests':
- changed-files:
- any-glob-to-any-file: 'pkgs/http_parser/**'
- any-glob-to-any-file: 'pkgs/http_client_conformance_tests/**'

'package:http_client_conformance_tests':
'package:http_multi_server':
- changed-files:
- any-glob-to-any-file: 'pkgs/http_multi_server/**'

'package:http_parser':
- changed-files:
- any-glob-to-any-file: 'pkgs/http_client_conformance_tests/**'
- any-glob-to-any-file: 'pkgs/http_parser/**'
70 changes: 70 additions & 0 deletions .github/workflows/http_multi_server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: package:http_multi_server

on:
push:
branches:
- master
paths:
- '.github/workflows/http_multi_server.yaml'
- 'pkgs/http_multi_server/**'
pull_request:
paths:
- '.github/workflows/http_multi_server.yaml'
- 'pkgs/http_multi_server/**'
schedule:
- cron: "0 0 * * 0"

defaults:
run:
working-directory: pkgs/http_multi_server/

env:
PUB_ENVIRONMENT: bot.github

jobs:
# Check code formatting and static analysis on a single OS (linux)
# against Dart dev.
analyze:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- name: Analyze code
run: dart analyze --fatal-infos
if: always() && steps.install.outcome == 'success'

# Run tests on a matrix consisting of two dimensions:
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
# 2. release channel: dev
test:
needs: analyze
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [3.2, dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
- name: Run VM tests
run: dart test --platform vm
if: always() && steps.install.outcome == 'success'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and the browser.
| [http](pkgs/http/) | A composable, multi-platform, Future-based API for HTTP requests. | [![pub package](https://img.shields.io/pub/v/http.svg)](https://pub.dev/packages/http) |
| [http2](pkgs/http2/) | A HTTP/2 implementation in Dart. | [![pub package](https://img.shields.io/pub/v/http2.svg)](https://pub.dev/packages/http2) |
| [http_client_conformance_tests](pkgs/http_client_conformance_tests/) | A library that tests whether implementations of package:http's `Client` class behave as expected. | |
| [http_multi_server](pkgs/http_multi_server/) | A `dart:io` `HttpServer` wrapper that handles requests from multiple servers. | [![pub package](https://img.shields.io/pub/v/http_multi_server.svg)](https://pub.dev/packages/http_multi_server) |
| [http_parser](pkgs/http_parser/) | A platform-independent package for parsing and serializing HTTP formats. | [![pub package](https://img.shields.io/pub/v/http_parser.svg)](https://pub.dev/packages/http_parser) |
| [http_profile](pkgs/http_profile/) | A library used by HTTP client authors to integrate with the DevTools Network View. | [![pub package](https://img.shields.io/pub/v/http_profile.svg)](https://pub.dev/packages/http_profile) |
| [ok_http](pkgs/ok_http/) | An Android Flutter plugin that provides access to the [OkHttp](https://square.github.io/okhttp/) HTTP client and the OkHttp [WebSocket](https://square.github.io/okhttp/5.x/okhttp/okhttp3/-web-socket/index.html) API. | [![pub package](https://img.shields.io/pub/v/ok_http.svg)](https://pub.dev/packages/ok_http) |
Expand Down
14 changes: 14 additions & 0 deletions pkgs/http_multi_server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Don’t commit the following directories created by pub.
.buildlog
.dart_tool/
.packages
build/

# Or the files created by dart2js.
*.dart.js
*.js_
*.js.deps
*.js.map

# Include when developing application packages.
pubspec.lock
5 changes: 5 additions & 0 deletions pkgs/http_multi_server/.test_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"test_package": {
"platforms": ["vm"]
}
}
113 changes: 113 additions & 0 deletions pkgs/http_multi_server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
## 3.2.2

* Require Dart 3.2
* Move to `dart-lang/http` monorepo.

## 3.2.1

* Populate the pubspec `repository` field.

## 3.2.0

* Honor the `preserveHeaderCase` argument to `MultiHeaders.set` and `.add`.

## 3.1.0

* Add `HttpMultiServer.bindSecure` to match `HttpMultiServer.bind`.

## 3.0.1

* Fix an issue where `bind` would bind to the `anyIPv6` address in unsupported
environments.

## 3.0.0

* Migrate to null safety.

## 2.2.0

* Preparation for [HttpHeaders change]. Update signature of `MultiHeaders.add()`
and `MultiHeaders.set()` to match new signature of `HttpHeaders`. The
parameter is not yet forwarded and will not behave as expected.

[HttpHeaders change]: https://github.com/dart-lang/sdk/issues/39657

## 2.1.0

* Add `HttpMultiServer.bind` static 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 `async` 2.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.13 `HttpServer.bindSecure()` signature. This removes the
`certificateName` named parameter and adds the required `context` parameter
and the named `v6Only` and `shared` parameters.

* Added `v6Only` and `shared` parameters to `HttpMultiServer.loopback()` to
match `HttpServer.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()` and `loopbackSecure()` 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.remove` and `.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.

[issue 19815]: https://code.google.com/p/dart/issues/detail?id=19815
27 changes: 27 additions & 0 deletions pkgs/http_multi_server/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2014, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 changes: 28 additions & 0 deletions pkgs/http_multi_server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[![Dart CI](https://github.com/dart-lang/http/actions/workflows/http_multi_server.yaml/badge.svg)](https://github.com/dart-lang/http/actions/workflows/http_multi_server.yaml)
[![pub package](https://img.shields.io/pub/v/http_multi_server.svg)](https://pub.dev/packages/http_multi_server)
[![package publisher](https://img.shields.io/pub/publisher/http_multi_server.svg)](https://pub.dev/packages/http_multi_server/publisher)

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][].

```dart
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!");
});
}
```

[HttpServer]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart-io.HttpServer

[HttpMultiServer.loopback]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/http_multi_server/http_multi_server.HttpMultiServer#id_loopback
25 changes: 25 additions & 0 deletions pkgs/http_multi_server/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# https://dart.dev/tools/analysis#the-analysis-options-file
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
language:
strict-casts: true

linter:
rules:
- avoid_bool_literals_in_conditional_expressions
- avoid_classes_with_only_static_members
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_returning_this
- avoid_unused_constructor_parameters
- cancel_subscriptions
- cascade_invocations
- join_return_with_assignment
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- no_runtimeType_toString
- prefer_const_declarations
- prefer_expression_function_bodies
- prefer_final_locals
- use_string_buffers
17 changes: 17 additions & 0 deletions pkgs/http_multi_server/example/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

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.
final server = await HttpMultiServer.loopback(8080);
shelf_io.serveRequests(
server,
(request) => shelf.Response.ok('Hello, world!'),
);
}
Loading
Loading