| 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:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:http_parser/http_parser.dart'; | 10 import 'package:http_parser/http_parser.dart'; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 /// print(request.url); // => dir/file.html | 203 /// print(request.url); // => dir/file.html |
| 204 /// | 204 /// |
| 205 /// request = request.change(path: "dir"); | 205 /// request = request.change(path: "dir"); |
| 206 /// print(request.handlerPath); // => /static/dir/ | 206 /// print(request.handlerPath); // => /static/dir/ |
| 207 /// print(request.url); // => file.html | 207 /// print(request.url); // => file.html |
| 208 Request change({Map<String, String> headers, Map<String, Object> context, | 208 Request change({Map<String, String> headers, Map<String, Object> context, |
| 209 String path, body}) { | 209 String path, body}) { |
| 210 headers = updateMap(this.headers, headers); | 210 headers = updateMap(this.headers, headers); |
| 211 context = updateMap(this.context, context); | 211 context = updateMap(this.context, context); |
| 212 | 212 |
| 213 if (body == null) body = this.read(); | 213 if (body == null) body = getBody(this); |
| 214 | 214 |
| 215 var handlerPath = this.handlerPath; | 215 var handlerPath = this.handlerPath; |
| 216 if (path != null) handlerPath += path; | 216 if (path != null) handlerPath += path; |
| 217 | 217 |
| 218 return new Request._(this.method, this.requestedUri, | 218 return new Request._(this.method, this.requestedUri, |
| 219 protocolVersion: this.protocolVersion, | 219 protocolVersion: this.protocolVersion, |
| 220 headers: headers, | 220 headers: headers, |
| 221 handlerPath: handlerPath, | 221 handlerPath: handlerPath, |
| 222 body: body, | 222 body: body, |
| 223 context: context, | 223 context: context, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 return handlerPath; | 346 return handlerPath; |
| 347 } else if (url != null) { | 347 } else if (url != null) { |
| 348 if (url.path.isEmpty) return requestedUri.path; | 348 if (url.path.isEmpty) return requestedUri.path; |
| 349 | 349 |
| 350 var index = requestedUri.path.indexOf(url.path); | 350 var index = requestedUri.path.indexOf(url.path); |
| 351 return requestedUri.path.substring(0, index); | 351 return requestedUri.path.substring(0, index); |
| 352 } else { | 352 } else { |
| 353 return '/'; | 353 return '/'; |
| 354 } | 354 } |
| 355 } | 355 } |
| OLD | NEW |