OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // | 4 // |
5 // VMOptions= | 5 // VMOptions= |
6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
9 | 9 |
10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 response.close(); | 81 response.close(); |
82 response.done.then((_) => server.close()); | 82 response.done.then((_) => server.close()); |
83 }); | 83 }); |
84 controller.close(); | 84 controller.close(); |
85 }, bytes: 0); | 85 }, bytes: 0); |
86 } | 86 } |
87 | 87 |
88 void testBadResponseAdd() { | 88 void testBadResponseAdd() { |
89 testServerRequest((server, request) { | 89 testServerRequest((server, request) { |
90 request.response.contentLength = 0; | 90 request.response.contentLength = 0; |
91 request.response.writeBytes([0]); | 91 request.response.add([0]); |
92 request.response.close(); | 92 request.response.close(); |
93 request.response.done.catchError((error) { | 93 request.response.done.catchError((error) { |
94 server.close(); | 94 server.close(); |
95 }, test: (e) => e is HttpException); | 95 }, test: (e) => e is HttpException); |
96 }); | 96 }); |
97 | 97 |
98 testServerRequest((server, request) { | 98 testServerRequest((server, request) { |
99 request.response.contentLength = 5; | 99 request.response.contentLength = 5; |
100 request.response.writeBytes([0, 0, 0]); | 100 request.response.add([0, 0, 0]); |
101 request.response.writeBytes([0, 0, 0]); | 101 request.response.add([0, 0, 0]); |
102 request.response.close(); | 102 request.response.close(); |
103 request.response.done.catchError((error) { | 103 request.response.done.catchError((error) { |
104 server.close(); | 104 server.close(); |
105 }, test: (e) => e is HttpException); | 105 }, test: (e) => e is HttpException); |
106 }); | 106 }); |
107 | 107 |
108 testServerRequest((server, request) { | 108 testServerRequest((server, request) { |
109 request.response.contentLength = 0; | 109 request.response.contentLength = 0; |
110 request.response.writeBytes(new Uint8List(64 * 1024)); | 110 request.response.add(new Uint8List(64 * 1024)); |
111 request.response.writeBytes(new Uint8List(64 * 1024)); | 111 request.response.add(new Uint8List(64 * 1024)); |
112 request.response.writeBytes(new Uint8List(64 * 1024)); | 112 request.response.add(new Uint8List(64 * 1024)); |
113 request.response.close(); | 113 request.response.close(); |
114 request.response.done.catchError((error) { | 114 request.response.done.catchError((error) { |
115 server.close(); | 115 server.close(); |
116 }, test: (e) => e is HttpException); | 116 }, test: (e) => e is HttpException); |
117 }); | 117 }); |
118 } | 118 } |
119 | 119 |
120 void testBadResponseClose() { | 120 void testBadResponseClose() { |
121 testServerRequest((server, request) { | 121 testServerRequest((server, request) { |
122 request.response.contentLength = 5; | 122 request.response.contentLength = 5; |
123 request.response.close(); | 123 request.response.close(); |
124 request.response.done.catchError((error) { | 124 request.response.done.catchError((error) { |
125 server.close(); | 125 server.close(); |
126 }, test: (e) => e is HttpException); | 126 }, test: (e) => e is HttpException); |
127 }); | 127 }); |
128 | 128 |
129 testServerRequest((server, request) { | 129 testServerRequest((server, request) { |
130 request.response.contentLength = 5; | 130 request.response.contentLength = 5; |
131 request.response.writeBytes([0]); | 131 request.response.add([0]); |
132 request.response.close(); | 132 request.response.close(); |
133 request.response.done.catchError((error) { | 133 request.response.done.catchError((error) { |
134 server.close(); | 134 server.close(); |
135 }, test: (e) => e is HttpException); | 135 }, test: (e) => e is HttpException); |
136 }); | 136 }); |
137 } | 137 } |
138 | 138 |
139 void main() { | 139 void main() { |
140 testResponseDone(); | 140 testResponseDone(); |
141 testResponseAddStream(); | 141 testResponseAddStream(); |
142 testBadResponseAdd(); | 142 testBadResponseAdd(); |
143 testBadResponseClose(); | 143 testBadResponseClose(); |
144 } | 144 } |
OLD | NEW |