mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:58:29 +00:00
7250fd6379
This reverts commit b8c5ecd5aa
.
TEST=N/A
Change-Id: I38bbebe1e38bc9dbfdde764eff847aafb3e39353
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200926
Reviewed-by: Siva Annamalai <asiva@google.com>
38 lines
1.5 KiB
Dart
38 lines
1.5 KiB
Dart
// Copyright (c) 2020, 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 'dart:async';
|
|
import 'dart:io';
|
|
|
|
import 'package:dds/dds.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
/// Simple socket server which immediately closes the first connection and
|
|
/// shuts down. This causes the HTTP request to the server to fail with a
|
|
/// WebSocketChannelException: connection closed before full header was
|
|
/// received failure, which should be caught and surfaced in a
|
|
/// [DartDevelopmentServiceException].
|
|
Future<Uri> startTestServer() async {
|
|
final server = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0);
|
|
server.listen((Socket request) async {
|
|
request.destroy();
|
|
await server.close();
|
|
});
|
|
return Uri(scheme: 'http', host: server.address.host, port: server.port);
|
|
}
|
|
|
|
/// Reproduction case for https://github.com/flutter/flutter/issues/69433
|
|
void main() async {
|
|
test('Handle connection closed before full header received', () async {
|
|
final uri = await startTestServer();
|
|
try {
|
|
await DartDevelopmentService.startDartDevelopmentService(uri);
|
|
fail('Unexpected successful connection.');
|
|
} on DartDevelopmentServiceException catch (e) {
|
|
expect(e.errorCode, DartDevelopmentServiceException.connectionError);
|
|
expect(e.toString().contains('WebSocketChannelException'), true);
|
|
}
|
|
});
|
|
}
|