Skip to content

Commit 658b4c4

Browse files
committed
Merge package:http_multi_server into the http monorepo
2 parents 79470d0 + 2b0b562 commit 658b4c4

16 files changed

+1213
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Dependabot configuration file.
2+
# See https://docs.github.com/en/code-security/dependabot/dependabot-version-updates
3+
version: 2
4+
5+
updates:
6+
- package-ecosystem: github-actions
7+
directory: /
8+
schedule:
9+
interval: monthly
10+
labels:
11+
- autosubmit
12+
groups:
13+
github-actions:
14+
patterns:
15+
- "*"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# A workflow to close issues where the author hasn't responded to a request for
2+
# more information; see https://github.com/actions/stale.
3+
4+
name: No Response
5+
6+
# Run as a daily cron.
7+
on:
8+
schedule:
9+
# Every day at 8am
10+
- cron: '0 8 * * *'
11+
12+
# All permissions not specified are set to 'none'.
13+
permissions:
14+
issues: write
15+
pull-requests: write
16+
17+
jobs:
18+
no-response:
19+
runs-on: ubuntu-latest
20+
if: ${{ github.repository_owner == 'dart-lang' }}
21+
steps:
22+
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e
23+
with:
24+
# Don't automatically mark inactive issues+PRs as stale.
25+
days-before-stale: -1
26+
# Close needs-info issues and PRs after 14 days of inactivity.
27+
days-before-close: 14
28+
stale-issue-label: "needs-info"
29+
close-issue-message: >
30+
Without additional information we're not able to resolve this issue.
31+
Feel free to add more info or respond to any questions above and we
32+
can reopen the case. Thanks for your contribution!
33+
stale-pr-label: "needs-info"
34+
close-pr-message: >
35+
Without additional information we're not able to resolve this PR.
36+
Feel free to add more info or respond to any questions above.
37+
Thanks for your contribution!
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# A CI configuration to auto-publish pub packages.
2+
3+
name: Publish
4+
5+
on:
6+
pull_request:
7+
branches: [ master ]
8+
push:
9+
tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ]
10+
11+
jobs:
12+
publish:
13+
if: ${{ github.repository_owner == 'dart-lang' }}
14+
uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main
15+
permissions:
16+
id-token: write # Required for authentication using OIDC
17+
pull-requests: write # Required for writing the pull request note
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Dart CI
2+
3+
on:
4+
# Run on PRs and pushes to the default branch.
5+
push:
6+
branches: [ master ]
7+
pull_request:
8+
branches: [ master ]
9+
schedule:
10+
- cron: "0 0 * * 0"
11+
12+
env:
13+
PUB_ENVIRONMENT: bot.github
14+
15+
jobs:
16+
# Check code formatting and static analysis on a single OS (linux)
17+
# against Dart dev.
18+
analyze:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
sdk: [dev]
24+
steps:
25+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
26+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
27+
with:
28+
sdk: ${{ matrix.sdk }}
29+
- id: install
30+
name: Install dependencies
31+
run: dart pub get
32+
- name: Check formatting
33+
run: dart format --output=none --set-exit-if-changed .
34+
if: always() && steps.install.outcome == 'success'
35+
- name: Analyze code
36+
run: dart analyze --fatal-infos
37+
if: always() && steps.install.outcome == 'success'
38+
39+
# Run tests on a matrix consisting of two dimensions:
40+
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
41+
# 2. release channel: dev
42+
test:
43+
needs: analyze
44+
runs-on: ${{ matrix.os }}
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
# Add macos-latest and/or windows-latest if relevant for this package.
49+
os: [ubuntu-latest]
50+
sdk: [3.2, dev]
51+
steps:
52+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
53+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
54+
with:
55+
sdk: ${{ matrix.sdk }}
56+
- id: install
57+
name: Install dependencies
58+
run: dart pub get
59+
- name: Run VM tests
60+
run: dart test --platform vm
61+
if: always() && steps.install.outcome == 'success'

pkgs/http_multi_server/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Don’t commit the following directories created by pub.
2+
.buildlog
3+
.dart_tool/
4+
.packages
5+
build/
6+
7+
# Or the files created by dart2js.
8+
*.dart.js
9+
*.js_
10+
*.js.deps
11+
*.js.map
12+
13+
# Include when developing application packages.
14+
pubspec.lock

pkgs/http_multi_server/.test_config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"test_package": {
3+
"platforms": ["vm"]
4+
}
5+
}

pkgs/http_multi_server/CHANGELOG.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
## 3.2.2-wip
2+
3+
* Require Dart 3.2
4+
5+
## 3.2.1
6+
7+
* Populate the pubspec `repository` field.
8+
9+
## 3.2.0
10+
11+
* Honor the `preserveHeaderCase` argument to `MultiHeaders.set` and `.add`.
12+
13+
## 3.1.0
14+
15+
* Add `HttpMultiServer.bindSecure` to match `HttpMultiServer.bind`.
16+
17+
## 3.0.1
18+
19+
* Fix an issue where `bind` would bind to the `anyIPv6` address in unsupported
20+
environments.
21+
22+
## 3.0.0
23+
24+
* Migrate to null safety.
25+
26+
## 2.2.0
27+
28+
* Preparation for [HttpHeaders change]. Update signature of `MultiHeaders.add()`
29+
and `MultiHeaders.set()` to match new signature of `HttpHeaders`. The
30+
parameter is not yet forwarded and will not behave as expected.
31+
32+
[HttpHeaders change]: https://github.com/dart-lang/sdk/issues/39657
33+
34+
## 2.1.0
35+
36+
* Add `HttpMultiServer.bind` static which centralizes logic around common local
37+
serving scenarios - handling a more flexible 'localhost' and listening on
38+
'any' hostname.
39+
* Update SDK constraints to `>=2.1.0 <3.0.0`.
40+
41+
## 2.0.6
42+
43+
* If there is a problem starting a loopback Ipv6 server, don't keep the Ipv4
44+
server open when throwing the exception.
45+
46+
## 2.0.5
47+
48+
* Update SDK constraints to `>=2.0.0-dev <3.0.0`.
49+
50+
## 2.0.4
51+
52+
* Declare support for `async` 2.0.0.
53+
54+
## 2.0.3
55+
56+
* Fix `HttpMultiServer.loopback()` and `.loopbackSecure()` for environments that
57+
don't support IPv4.
58+
59+
## 2.0.2
60+
61+
* Fix a dependency that was incorrectly marked as dev-only.
62+
63+
## 2.0.1
64+
65+
* Fix most strong mode errors and warnings.
66+
67+
## 2.0.0
68+
69+
* **Breaking:** Change the signature of `HttpMultiServer.loopbackSecure()` to
70+
match the new Dart 1.13 `HttpServer.bindSecure()` signature. This removes the
71+
`certificateName` named parameter and adds the required `context` parameter
72+
and the named `v6Only` and `shared` parameters.
73+
74+
* Added `v6Only` and `shared` parameters to `HttpMultiServer.loopback()` to
75+
match `HttpServer.bind()`.
76+
77+
## 1.3.2
78+
79+
* Eventually stop retrying port allocation if it fails repeatedly.
80+
81+
* Properly detect socket errors caused by already-in-use addresses.
82+
83+
## 1.3.1
84+
85+
* `loopback()` and `loopbackSecure()` recover gracefully if an ephemeral port is
86+
requested and the located port isn't available on both IPv4 and IPv6.
87+
88+
## 1.3.0
89+
90+
* Add support for `HttpServer.autoCompress`.
91+
92+
## 1.2.0
93+
94+
* Add support for `HttpServer.defaultResponseHeaders.clear`.
95+
96+
* Fix `HttpServer.defaultResponseHeaders.remove` and `.removeAll`.
97+
98+
## 1.1.0
99+
100+
* Add support for `HttpServer.defaultResponseHeaders`.
101+
102+
## 1.0.2
103+
104+
* Remove the workaround for [issue 19815][].
105+
106+
## 1.0.1
107+
108+
* Ignore errors from one of the servers if others are still bound. In
109+
particular, this works around [issue 19815][] on some Windows machines where
110+
IPv6 failure isn't discovered until we try to connect to the socket.
111+
112+
[issue 19815]: https://code.google.com/p/dart/issues/detail?id=19815

pkgs/http_multi_server/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright 2014, the Dart project authors.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are
5+
met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following
11+
disclaimer in the documentation and/or other materials provided
12+
with the distribution.
13+
* Neither the name of Google LLC nor the names of its
14+
contributors may be used to endorse or promote products derived
15+
from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pkgs/http_multi_server/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[![Dart CI](https://github.com/dart-lang/http_multi_server/actions/workflows/test-package.yml/badge.svg)](https://github.com/dart-lang/http_multi_server/actions/workflows/test-package.yml)
2+
[![pub package](https://img.shields.io/pub/v/http_multi_server.svg)](https://pub.dev/packages/http_multi_server)
3+
[![package publisher](https://img.shields.io/pub/publisher/http_multi_server.svg)](https://pub.dev/packages/http_multi_server/publisher)
4+
5+
An implementation of `dart:io`'s [HttpServer][] that wraps multiple servers and
6+
forwards methods to all of them. It's useful for serving the same application on
7+
multiple network interfaces while still having a unified way of controlling the
8+
servers. In particular, it supports serving on both the IPv4 and IPv6 loopback
9+
addresses using [HttpMultiServer.loopback][].
10+
11+
```dart
12+
import 'package:http_multi_server/http_multi_server.dart';
13+
import 'package:shelf/shelf.dart' as shelf;
14+
import 'package:shelf/shelf_io.dart' as shelf_io;
15+
16+
void main() async {
17+
// Both http://127.0.0.1:8080 and http://[::1]:8080 will be bound to the same
18+
// server.
19+
var server = await HttpMultiServer.loopback(8080);
20+
shelf_io.serveRequests(server, (request) {
21+
return shelf.Response.ok("Hello, world!");
22+
});
23+
}
24+
```
25+
26+
[HttpServer]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart-io.HttpServer
27+
28+
[HttpMultiServer.loopback]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/http_multi_server/http_multi_server.HttpMultiServer#id_loopback
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# https://dart.dev/tools/analysis#the-analysis-options-file
2+
include: package:dart_flutter_team_lints/analysis_options.yaml
3+
4+
analyzer:
5+
language:
6+
strict-casts: true
7+
8+
linter:
9+
rules:
10+
- avoid_bool_literals_in_conditional_expressions
11+
- avoid_classes_with_only_static_members
12+
- avoid_private_typedef_functions
13+
- avoid_redundant_argument_values
14+
- avoid_returning_this
15+
- avoid_unused_constructor_parameters
16+
- cancel_subscriptions
17+
- cascade_invocations
18+
- join_return_with_assignment
19+
- literal_only_boolean_expressions
20+
- no_adjacent_strings_in_list
21+
- no_runtimeType_toString
22+
- prefer_const_declarations
23+
- prefer_expression_function_bodies
24+
- prefer_final_locals
25+
- use_string_buffers

0 commit comments

Comments
 (0)