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

Side by Side Diff: lib/src/request.dart

Issue 1648723002: Fix the old-hijack test. (Closed) Base URL: git@github.com:dart-lang/shelf@master
Patch Set: Created 4 years, 10 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 | « no previous file | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 7
8 import 'package:http_parser/http_parser.dart'; 8 import 'package:http_parser/http_parser.dart';
9 import 'package:stream_channel/stream_channel.dart'; 9 import 'package:stream_channel/stream_channel.dart';
10 10
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 /// 239 ///
240 /// This may only be called when using a Shelf adapter that supports 240 /// This may only be called when using a Shelf adapter that supports
241 /// hijacking, such as the `dart:io` adapter. In addition, a given request may 241 /// hijacking, such as the `dart:io` adapter. In addition, a given request may
242 /// only be hijacked once. [canHijack] can be used to detect whether this 242 /// only be hijacked once. [canHijack] can be used to detect whether this
243 /// request can be hijacked. 243 /// request can be hijacked.
244 void hijack(Function callback) { 244 void hijack(Function callback) {
245 if (_onHijack == null) { 245 if (_onHijack == null) {
246 throw new StateError("This request can't be hijacked."); 246 throw new StateError("This request can't be hijacked.");
247 } 247 }
248 248
249 if (callback is ZoneUnaryCallback) { 249 if (callback is! ZoneBinaryCallback) {
250 var oldCallback = callback; 250 var oldCallback = callback;
251 callback = (stream, sink) { 251 callback = (stream, sink) {
252 oldCallback(new StreamChannel<List<int>>(stream, sink)); 252 oldCallback(new StreamChannel<List<int>>(stream, sink));
253 }; 253 };
254 } 254 }
255 255
256 _onHijack.run(callback); 256 _onHijack.run(callback);
257 throw const HijackException(); 257 throw const HijackException();
258 } 258 }
259 } 259 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 return handlerPath; 354 return handlerPath;
355 } else if (url != null) { 355 } else if (url != null) {
356 if (url.path.isEmpty) return requestedUri.path; 356 if (url.path.isEmpty) return requestedUri.path;
357 357
358 var index = requestedUri.path.indexOf(url.path); 358 var index = requestedUri.path.indexOf(url.path);
359 return requestedUri.path.substring(0, index); 359 return requestedUri.path.substring(0, index);
360 } else { 360 } else {
361 return '/'; 361 return '/';
362 } 362 }
363 } 363 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698