Skip to content

Update to latest lints, required Dart 3.7 #55

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

Merged
merged 2 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ jobs:
publish:
if: ${{ github.repository_owner == 'google' }}
uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main
permissions:
id-token: write # Required for authentication using OIDC
pull-requests: write # Required for writing the pull request note
2 changes: 1 addition & 1 deletion .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [3.0, dev]
sdk: [3.7, dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 0.3.2-wip

* Require Dart 3.0
* Require Dart 3.7

## 0.3.1

Expand Down
28 changes: 17 additions & 11 deletions lib/src/sync_http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class SyncHttpClientRequest {
final RawSynchronousSocket _socket;

SyncHttpClientRequest._(this.method, this.uri, bool body)
: _body = body ? BytesBuilder() : null,
_socket = RawSynchronousSocket.connectSync(uri.host, uri.port);
: _body = body ? BytesBuilder() : null,
_socket = RawSynchronousSocket.connectSync(uri.host, uri.port);

/// Write content into the body of the HTTP request.
void write(Object? obj) {
Expand Down Expand Up @@ -259,7 +259,7 @@ class _SyncHttpClientRequestHeaders implements HttpHeaders {
HttpHeaders.connectionHeader,
HttpHeaders.contentLengthHeader,
HttpHeaders.contentTypeHeader,
HttpHeaders.hostHeader
HttpHeaders.hostHeader,
].forEach(forEachFunc);
_headers.keys.forEach(forEachFunc);
}
Expand Down Expand Up @@ -401,7 +401,8 @@ class SyncHttpClientResponse {
headers[name]!.add(value);
} else if (line.startsWith('HTTP/1.1') || line.startsWith('HTTP/1.0')) {
statusCode = int.parse(
line.substring('HTTP/1.x '.length, 'HTTP/1.x xxx'.length));
line.substring('HTTP/1.x '.length, 'HTTP/1.x xxx'.length),
);
reasonPhrase = line.substring('HTTP/1.x xxx '.length);
inHeader = true;
} else {
Expand Down Expand Up @@ -430,15 +431,20 @@ class SyncHttpClientResponse {
}
}

return SyncHttpClientResponse._(headers,
reasonPhrase: reasonPhrase,
statusCode: statusCode,
body: body.toString());
return SyncHttpClientResponse._(
headers,
reasonPhrase: reasonPhrase,
statusCode: statusCode,
body: body.toString(),
);
}

SyncHttpClientResponse._(Map<String, List<String>> headers,
{this.reasonPhrase, this.statusCode, this.body})
: headers = _SyncHttpClientResponseHeaders(headers);
SyncHttpClientResponse._(
Map<String, List<String>> headers, {
this.reasonPhrase,
this.statusCode,
this.body,
}) : headers = _SyncHttpClientResponseHeaders(headers);
}

class _SyncHttpClientResponseHeaders implements HttpHeaders {
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: Synchronous HTTP client for Dart.
repository: https://github.com/google/sync_http.dart

environment:
sdk: ^3.0.0
sdk: ^3.7.0

dev_dependencies:
dart_flutter_team_lints: ^2.0.0
test: ^1.16.0
dart_flutter_team_lints: ^3.0.0
test: ^1.16.6
35 changes: 17 additions & 18 deletions test/http_basic_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ class TestServerMain {
}
}

enum TestServerCommandState {
start,
stop,
}
enum TestServerCommandState { start, stop }

class TestServerCommand {
TestServerCommand.start() : _command = TestServerCommandState.start;
Expand All @@ -66,11 +63,7 @@ class TestServerCommand {
final TestServerCommandState _command;
}

enum TestServerStatusState {
started,
stopped,
error,
}
enum TestServerStatusState { started, stopped, error }

class TestServerStatus {
TestServerStatus.started(this._port) : _state = TestServerStatusState.started;
Expand Down Expand Up @@ -226,8 +219,9 @@ Future<void> testGET() async {
final completer = Completer<void>();
final testServerMain = TestServerMain();
testServerMain.setServerStartedHandler((int? port) {
final request =
SyncHttpClient.getUrl(Uri.http('localhost:$port', '/0123456789'));
final request = SyncHttpClient.getUrl(
Uri.http('localhost:$port', '/0123456789'),
);
final response = request.close();
expect(HttpStatus.ok, equals(response.statusCode));
expect(11, equals(response.contentLength));
Expand All @@ -249,8 +243,9 @@ Future<void> testPOST() async {
void runTest(int? port) {
var count = 0;
void sendRequest() {
final request =
SyncHttpClient.postUrl(Uri.http('localhost:$port', '/echo'));
final request = SyncHttpClient.postUrl(
Uri.http('localhost:$port', '/echo'),
);
request.write(data);
final response = request.close();
expect(HttpStatus.ok, equals(response.statusCode));
Expand All @@ -276,8 +271,9 @@ Future<void> test404() async {
final completer = Completer<void>();
final testServerMain = TestServerMain();
testServerMain.setServerStartedHandler((int? port) {
final request =
SyncHttpClient.getUrl(Uri.http('localhost:$port', '/thisisnotfound'));
final request = SyncHttpClient.getUrl(
Uri.http('localhost:$port', '/thisisnotfound'),
);
final response = request.close();
expect(HttpStatus.notFound, equals(response.statusCode));
expect('Page not found', equals(response.body));
Expand All @@ -292,12 +288,15 @@ Future<void> testReasonPhrase() async {
final completer = Completer<void>();
final testServerMain = TestServerMain();
testServerMain.setServerStartedHandler((int? port) {
final request =
SyncHttpClient.getUrl(Uri.http('localhost:$port', '/reasonformoving'));
final request = SyncHttpClient.getUrl(
Uri.http('localhost:$port', '/reasonformoving'),
);
final response = request.close();
expect(HttpStatus.movedPermanently, equals(response.statusCode));
expect(
"Don't come looking here any more\r\n", equals(response.reasonPhrase));
"Don't come looking here any more\r\n",
equals(response.reasonPhrase),
);
testServerMain.close();
completer.complete();
});
Expand Down