| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 base_request; | 5 library base_request; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 10 import 'dart:uri'; | 10 import 'dart:uri'; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // TODO(nweiz): make this a HttpHeaders object | 75 // TODO(nweiz): make this a HttpHeaders object |
| 76 /// The headers for this request. | 76 /// The headers for this request. |
| 77 final Map<String, String> headers; | 77 final Map<String, String> headers; |
| 78 | 78 |
| 79 /// Whether the request has been finalized. | 79 /// Whether the request has been finalized. |
| 80 bool get finalized => _finalized; | 80 bool get finalized => _finalized; |
| 81 bool _finalized = false; | 81 bool _finalized = false; |
| 82 | 82 |
| 83 /// Creates a new HTTP request. | 83 /// Creates a new HTTP request. |
| 84 BaseRequest(this.method, this.url) | 84 BaseRequest(this.method, this.url) |
| 85 : headers = <String>{}; | 85 : headers = <String, String>{}; |
| 86 | 86 |
| 87 /// Finalizes the HTTP request in preparation for it being sent. This freezes | 87 /// Finalizes the HTTP request in preparation for it being sent. This freezes |
| 88 /// all mutable fields and returns a single-subscription [ByteStream] that | 88 /// all mutable fields and returns a single-subscription [ByteStream] that |
| 89 /// emits the body of the request. | 89 /// emits the body of the request. |
| 90 /// | 90 /// |
| 91 /// The base implementation of this returns null rather than a [ByteStream]; | 91 /// The base implementation of this returns null rather than a [ByteStream]; |
| 92 /// subclasses are responsible for creating the return value, which should be | 92 /// subclasses are responsible for creating the return value, which should be |
| 93 /// single-subscription to ensure that no data is dropped. They should also | 93 /// single-subscription to ensure that no data is dropped. They should also |
| 94 /// freeze any additional mutable fields they add that don't make sense to | 94 /// freeze any additional mutable fields they add that don't make sense to |
| 95 /// change after the request headers are sent. | 95 /// change after the request headers are sent. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 126 } | 126 } |
| 127 | 127 |
| 128 /// Throws an error if this request has been finalized. | 128 /// Throws an error if this request has been finalized. |
| 129 void _checkFinalized() { | 129 void _checkFinalized() { |
| 130 if (!finalized) return; | 130 if (!finalized) return; |
| 131 throw new StateError("Can't modify a finalized Request."); | 131 throw new StateError("Can't modify a finalized Request."); |
| 132 } | 132 } |
| 133 | 133 |
| 134 String toString() => "$method $url"; | 134 String toString() => "$method $url"; |
| 135 } | 135 } |
| OLD | NEW |