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

Side by Side Diff: pkg/http/lib/src/base_request.dart

Issue 137473003: Stop working around issue 16029 in pkg/http. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/http/pubspec.yaml » ('j') | 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) 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 8
9 import 'byte_stream.dart'; 9 import 'byte_stream.dart';
10 import 'client.dart'; 10 import 'client.dart';
(...skipping 14 matching lines...) Expand all
25 25
26 /// The URL to which the request will be sent. 26 /// The URL to which the request will be sent.
27 final Uri url; 27 final Uri url;
28 28
29 /// The size of the request body, in bytes. This defaults to -1, which 29 /// The size of the request body, in bytes. This defaults to -1, which
30 /// indicates that the size of the request is not known in advance. 30 /// indicates that the size of the request is not known in advance.
31 int get contentLength => _contentLength; 31 int get contentLength => _contentLength;
32 int _contentLength = -1; 32 int _contentLength = -1;
33 33
34 set contentLength(int value) { 34 set contentLength(int value) {
35 _baseCheckFinalized(); 35 _checkFinalized();
36 _contentLength = value; 36 _contentLength = value;
37 } 37 }
38 38
39 /// Whether a persistent connection should be maintained with the server. 39 /// Whether a persistent connection should be maintained with the server.
40 /// Defaults to true. 40 /// Defaults to true.
41 bool get persistentConnection => _persistentConnection; 41 bool get persistentConnection => _persistentConnection;
42 bool _persistentConnection = true; 42 bool _persistentConnection = true;
43 43
44 set persistentConnection(bool value) { 44 set persistentConnection(bool value) {
45 _baseCheckFinalized(); 45 _checkFinalized();
46 _persistentConnection = value; 46 _persistentConnection = value;
47 } 47 }
48 48
49 /// Whether the client should follow redirects while resolving this request. 49 /// Whether the client should follow redirects while resolving this request.
50 /// Defaults to true. 50 /// Defaults to true.
51 bool get followRedirects => _followRedirects; 51 bool get followRedirects => _followRedirects;
52 bool _followRedirects = true; 52 bool _followRedirects = true;
53 53
54 set followRedirects(bool value) { 54 set followRedirects(bool value) {
55 _baseCheckFinalized(); 55 _checkFinalized();
56 _followRedirects = value; 56 _followRedirects = value;
57 } 57 }
58 58
59 /// The maximum number of redirects to follow when [followRedirects] is true. 59 /// The maximum number of redirects to follow when [followRedirects] is true.
60 /// If this number is exceeded the [BaseResponse] future will signal a 60 /// If this number is exceeded the [BaseResponse] future will signal a
61 /// [RedirectException]. Defaults to 5. 61 /// [RedirectException]. Defaults to 5.
62 int get maxRedirects => _maxRedirects; 62 int get maxRedirects => _maxRedirects;
63 int _maxRedirects = 5; 63 int _maxRedirects = 5;
64 64
65 set maxRedirects(int value) { 65 set maxRedirects(int value) {
66 _baseCheckFinalized(); 66 _checkFinalized();
67 _maxRedirects = value; 67 _maxRedirects = value;
68 } 68 }
69 69
70 // TODO(nweiz): automatically parse cookies from headers 70 // TODO(nweiz): automatically parse cookies from headers
71 71
72 // TODO(nweiz): make this a HttpHeaders object 72 // TODO(nweiz): make this a HttpHeaders object
73 /// The headers for this request. 73 /// The headers for this request.
74 final Map<String, String> headers; 74 final Map<String, String> headers;
75 75
76 /// Whether the request has been finalized. 76 /// Whether the request has been finalized.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 isRedirect: response.isRedirect, 116 isRedirect: response.isRedirect,
117 persistentConnection: response.persistentConnection, 117 persistentConnection: response.persistentConnection,
118 reasonPhrase: response.reasonPhrase); 118 reasonPhrase: response.reasonPhrase);
119 }).catchError((e) { 119 }).catchError((e) {
120 client.close(); 120 client.close();
121 throw e; 121 throw e;
122 }); 122 });
123 } 123 }
124 124
125 // Throws an error if this request has been finalized. 125 // Throws an error if this request has been finalized.
126 // TODO(nweiz): rename to _checkFinalized once 16029 is resolved 126 void _checkFinalized() {
127 void _baseCheckFinalized() {
128 if (!finalized) return; 127 if (!finalized) return;
129 throw new StateError("Can't modify a finalized Request."); 128 throw new StateError("Can't modify a finalized Request.");
130 } 129 }
131 130
132 String toString() => "$method $url"; 131 String toString() => "$method $url";
133 } 132 }
OLDNEW
« no previous file with comments | « no previous file | pkg/http/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698