| OLD | NEW |
| 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 library shelf.util; | |
| 6 | |
| 7 import 'dart:async'; | 5 import 'dart:async'; |
| 8 | 6 |
| 9 /// Like [new Future], but avoids around issue 11911 by using [new Future.value] | 7 /// Like [new Future], but avoids around issue 11911 by using [new Future.value] |
| 10 /// under the covers. | 8 /// under the covers. |
| 11 Future newFuture(callback()) => new Future.value().then((_) => callback()); | 9 Future newFuture(callback()) => new Future.value().then((_) => callback()); |
| 12 | 10 |
| 13 /// Run [callback] and capture any errors that would otherwise be top-leveled. | 11 /// Run [callback] and capture any errors that would otherwise be top-leveled. |
| 14 /// | 12 /// |
| 15 /// If [this] is called in a non-root error zone, it will just run [callback] | 13 /// If [this] is called in a non-root error zone, it will just run [callback] |
| 16 /// and return the result. Otherwise, it will capture any errors using | 14 /// and return the result. Otherwise, it will capture any errors using |
| (...skipping 21 matching lines...) Expand all Loading... |
| 38 | 36 |
| 39 /// Adds a header with [name] and [value] to [headers], which may be null. | 37 /// Adds a header with [name] and [value] to [headers], which may be null. |
| 40 /// | 38 /// |
| 41 /// Returns a new map without modifying [headers]. | 39 /// Returns a new map without modifying [headers]. |
| 42 Map<String, String> addHeader( | 40 Map<String, String> addHeader( |
| 43 Map<String, String> headers, String name, String value) { | 41 Map<String, String> headers, String name, String value) { |
| 44 headers = headers == null ? {} : new Map.from(headers); | 42 headers = headers == null ? {} : new Map.from(headers); |
| 45 headers[name] = value; | 43 headers[name] = value; |
| 46 return headers; | 44 return headers; |
| 47 } | 45 } |
| OLD | NEW |