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

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

Issue 14840009: Clear http session object on destroy. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/http_impl.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
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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 const SESSION_ID = "DARTSESSID"; 9 const SESSION_ID = "DARTSESSID";
10 10
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 Expect.equals(id, getSessionId(response.cookies)); 143 Expect.equals(id, getSessionId(response.cookies));
144 server.close(); 144 server.close();
145 client.close(); 145 client.close();
146 }); 146 });
147 }); 147 });
148 }); 148 });
149 }); 149 });
150 }); 150 });
151 } 151 }
152 152
153 void testSessionsDestroy() {
154 HttpServer.bind("127.0.0.1", 0).then((server) {
155 bool firstHit = false;
156 server.listen((request) {
157 var session = request.session;
158 if (session.isNew) {
159 Expect.isFalse(firstHit);
160 firstHit = true;
161 } else {
162 Expect.isTrue(firstHit);
163 session.destroy();
164 var session2 = request.session;
165 Expect.notEquals(session.id, session2.id);
166 };
167 request.response.close();
168 });
169
170 var client = new HttpClient();
171 client.get("127.0.0.1", server.port, "/")
172 .then((request) => request.close())
173 .then((response) {
174 response.listen((_) {}, onDone: () {
175 var id = getSessionId(response.cookies);
176 Expect.isNotNull(id);
177 client.get("127.0.0.1", server.port, "/")
178 .then((request) {
179 request.cookies.add(new Cookie(SESSION_ID, id));
180 return request.close();
181 })
182 .then((response) {
183 response.listen((_) {}, onDone: () {
184 Expect.isTrue(firstHit);
185 Expect.notEquals(id, getSessionId(response.cookies));
186 server.close();
187 client.close();
188 });
189 });
190 });
191 });
192 });
193 }
194
153 void main() { 195 void main() {
154 testSessions(1); 196 testSessions(1);
155 testTimeout(5); 197 testTimeout(5);
156 testSessionsData(); 198 testSessionsData();
199 testSessionsDestroy();
157 } 200 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698