| 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.request; | 5 library shelf.request; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 // TODO(kevmoo): use UnmodifiableMapView from SDK once 1.4 ships | 10 // TODO(kevmoo): use UnmodifiableMapView from SDK once 1.4 ships |
| 11 import 'package:collection/wrappers.dart' as pc; | 11 import 'package:collection/wrappers.dart' as pc; |
| 12 import 'package:http_parser/http_parser.dart'; |
| 12 import 'package:path/path.dart' as p; | 13 import 'package:path/path.dart' as p; |
| 13 | 14 |
| 14 import 'message.dart'; | 15 import 'message.dart'; |
| 15 import 'util.dart'; | |
| 16 | 16 |
| 17 /// Represents an HTTP request to be processed by a Shelf application. | 17 /// Represents an HTTP request to be processed by a Shelf application. |
| 18 class Request extends Message { | 18 class Request extends Message { |
| 19 /// The remainder of the [requestedUri] path designating the virtual | 19 /// The remainder of the [requestedUri] path designating the virtual |
| 20 /// "location" of the request's target within the handler. | 20 /// "location" of the request's target within the handler. |
| 21 /// | 21 /// |
| 22 /// [pathInfo] may be an empty string, if [requestedUri ]targets the handler | 22 /// [pathInfo] may be an empty string, if [requestedUri ]targets the handler |
| 23 /// root and does not have a trailing slash. | 23 /// root and does not have a trailing slash. |
| 24 /// | 24 /// |
| 25 /// [pathInfo] is never null. If it is not empty, it will start with `/`. | 25 /// [pathInfo] is never null. If it is not empty, it will start with `/`. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 /// Convenience property to access [pathInfo] data as a [List]. | 99 /// Convenience property to access [pathInfo] data as a [List]. |
| 100 List<String> get pathSegments { | 100 List<String> get pathSegments { |
| 101 var segs = p.url.split(pathInfo); | 101 var segs = p.url.split(pathInfo); |
| 102 if (segs.length > 0) { | 102 if (segs.length > 0) { |
| 103 assert(segs.first == p.url.separator); | 103 assert(segs.first == p.url.separator); |
| 104 segs.removeAt(0); | 104 segs.removeAt(0); |
| 105 } | 105 } |
| 106 return segs; | 106 return segs; |
| 107 } | 107 } |
| 108 } | 108 } |
| OLD | NEW |