Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: tests/standalone/io/http_loopback_test.dart

Issue 2931623003: Updated HttpServer documentation to specify that only IPv6 connections can be made when specifying … (Closed)
Patch Set: Added await to close() calls Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sdk/lib/io/http.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "dart:io";
6 import "dart:async";
7 import "package:expect/expect.dart";
8
9 RawServerSocket server;
10 RawSocket client;
11
12 void serverListen(RawSocket serverSide) async {
zra 2017/06/08 21:45:21 The analyzer will complain about this because asyn
bkonyi 2017/06/08 22:49:37 I've gone ahead and removed the void token from th
13 void serveData(RawSocketEvent event) async {
zra 2017/06/08 21:45:21 ditto
bkonyi 2017/06/08 22:49:37 Done.
14 serverSide.shutdown(SocketDirection.SEND);
15 await server.close();
zra 2017/06/08 21:45:21 server is already closed below in the finally bloc
bkonyi 2017/06/08 22:49:38 You're right, I just forgot to remove this. Done.
16 }
17
18 serverSide.listen(serveData);
19 }
20
21 IPv4ToIPv6FailureTest() async {
22 server = await RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V6, 0);
23 server.listen(serverListen);
24 bool testFailure = false;
25 try {
26 client =
27 await RawSocket.connect(InternetAddress.LOOPBACK_IP_V4, server.port);
28 await client.close();
29 testFailure = true;
30 } on SocketException catch (e) {
31 // We shouldn't be able to connect to the IPv6 loopback adapter using the
32 // IPv4 loopback address.
33 } catch (e) {
34 testFailure = true;
35 } finally {
36 Expect.equals(testFailure, false);
37 await server.close();
38 }
39 }
40
41 IPv6ToIPv4FailureTest() async {
42 server = await RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0);
43 server.listen(serverListen);
44 bool testFailure = false;
45 try {
46 client =
47 await RawSocket.connect(InternetAddress.LOOPBACK_IP_V6, server.port);
48 await client.close();
49 testFailure = true;
50 } on SocketException catch (e) {
51 // We shouldn't be able to connect to the IPv4 loopback adapter using the
52 // IPv6 loopback address.
53 } catch (e) {
54 testFailure = true;
55 } finally {
56 Expect.equals(testFailure, false);
57 await server.close();
58 }
59 }
60
61 loopbackSuccessTest(InternetAddress address) async {
62 server = await RawServerSocket.bind(address, 0);
63 server.listen(serverListen);
64 bool testFailure = false;
65 try {
66 client = await RawSocket.connect(address, server.port);
67 await client.close();
68 } catch (e) {
69 testFailure = true;
70 } finally {
71 Expect.equals(testFailure, false);
72 await server.close();
73 }
74 }
75
76 void main() async {
77 await IPv4ToIPv6FailureTest();
78 await IPv6ToIPv4FailureTest();
79 await loopbackSuccessTest(InternetAddress.LOOPBACK_IP_V4);
80 await loopbackSuccessTest(InternetAddress.LOOPBACK_IP_V6);
81 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698