Skip to content
Draft
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
4 changes: 4 additions & 0 deletions pkgs/http2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
stream when a stream is cancelled; drop the stream's queued `DATA` instead.
- Stop head-of-line blocking `HEADERS`, `RST_STREAM`, and `GOAWAY` behind
`DATA` that is waiting for connection-level flow-control credit.
- `StreamException` (a stream reset because of a `GOAWAY` or oversized headers)
now extends `StreamTransportException`, as documented for `TransportException`
subclasses. `MultiProtocolHttpServer.startServing` forwards an unexpected ALPN
protocol to `onError` instead of throwing inside the socket listener.

## 3.1.0

Expand Down
9 changes: 8 additions & 1 deletion pkgs/http2/lib/multiprotocol_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,14 @@ class MultiProtocolHttpServer {
);
} else {
socket.destroy();
throw Exception('Unexpected negotiated ALPN protocol: $protocol.');
final error = Exception(
'Unexpected negotiated ALPN protocol: $protocol.',
);
if (onError != null) {
onError(error, StackTrace.current);
} else {
throw error;
}
}
}, onError: onError);

Expand Down
20 changes: 12 additions & 8 deletions pkgs/http2/lib/src/sync_errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 '../transport.dart';

class ProtocolException implements Exception {
final String _message;

Expand Down Expand Up @@ -44,27 +46,29 @@ class TerminatedException implements Exception {
String toString() => 'TerminatedException: The object has been terminated.';
}

class StreamException implements Exception {
final String _message;
class StreamException extends StreamTransportException {
final int streamId;
final String _details;

StreamException(this.streamId, this._message);
StreamException(this.streamId, String details)
: _details = details,
super(details);

@override
String toString() => 'StreamException(stream id: $streamId): $_message';
String toString() => 'StreamException(stream id: $streamId): $_details';
}

class StreamClosedException extends StreamException {
StreamClosedException(super.streamId, [super.message = '']);
StreamClosedException(super.streamId, [super.details = '']);

@override
String toString() => 'StreamClosedException(stream id: $streamId): $_message';
String toString() => 'StreamClosedException(stream id: $streamId): $_details';
}

class StreamRefusedException extends StreamException {
StreamRefusedException(super.streamId, [super.message = '']);
StreamRefusedException(super.streamId, [super.details = '']);

@override
String toString() =>
'StreamRefusedException(stream id: $streamId): $_message';
'StreamRefusedException(stream id: $streamId): $_details';
}
3 changes: 2 additions & 1 deletion pkgs/http2/test/client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,8 @@ void main() {
// Make sure we don't get messages/pushes on the terminated stream.
unawaited(
stream.incomingMessages.toList().catchError(
expectAsync1((e) {
expectAsync1((Object e) {
expect(e, isA<StreamTransportException>());
expect(
'$e',
contains(
Expand Down
Loading