-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1416 from dart-lang/merge-http_multi_server-package
Merge `package:http_multi_server`
- Loading branch information
Showing
16 changed files
with
1,177 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"test_package": { | ||
"platforms": ["vm"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'), | ||
); | ||
} |
Oops, something went wrong.