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

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

Issue 23450003: Add encoding tests to pkg/http. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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/lib/src/utils.dart » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 request; 5 library request;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:typed_data'; 9 import 'dart:typed_data';
10 10
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 /// `application/x-www-form-urlencoded`. 114 /// `application/x-www-form-urlencoded`.
115 /// 115 ///
116 /// This map should only be set, not modified in place. 116 /// This map should only be set, not modified in place.
117 Map<String, String> get bodyFields { 117 Map<String, String> get bodyFields {
118 if (_contentType == null || 118 if (_contentType == null ||
119 _contentType.value != "application/x-www-form-urlencoded") { 119 _contentType.value != "application/x-www-form-urlencoded") {
120 throw new StateError('Cannot access the body fields of a Request without ' 120 throw new StateError('Cannot access the body fields of a Request without '
121 'content-type "application/x-www-form-urlencoded".'); 121 'content-type "application/x-www-form-urlencoded".');
122 } 122 }
123 123
124 return queryToMap(body); 124 return queryToMap(body, encoding: encoding);
125 } 125 }
126 126
127 set bodyFields(Map<String, String> fields) { 127 set bodyFields(Map<String, String> fields) {
128 if (_contentType == null) { 128 if (_contentType == null) {
129 _contentType = new ContentType("application", "x-www-form-urlencoded"); 129 _contentType = new ContentType("application", "x-www-form-urlencoded");
130 } else if (_contentType.value != "application/x-www-form-urlencoded") { 130 } else if (_contentType.value != "application/x-www-form-urlencoded") {
131 throw new StateError('Cannot set the body fields of a Request with ' 131 throw new StateError('Cannot set the body fields of a Request with '
132 'content-type "${_contentType.value}".'); 132 'content-type "${_contentType.value}".');
133 } 133 }
134 134
135 this.body = mapToQuery(fields); 135 this.body = mapToQuery(fields, encoding: encoding);
136 } 136 }
137 137
138 /// Creates a new HTTP request. 138 /// Creates a new HTTP request.
139 Request(String method, Uri url) 139 Request(String method, Uri url)
140 : super(method, url), 140 : super(method, url),
141 _defaultEncoding = UTF8, 141 _defaultEncoding = UTF8,
142 _bodyBytes = new Uint8List(0); 142 _bodyBytes = new Uint8List(0);
143 143
144 /// Freezes all mutable fields and returns a single-subscription [ByteStream] 144 /// Freezes all mutable fields and returns a single-subscription [ByteStream]
145 /// containing the request body. 145 /// containing the request body.
(...skipping 13 matching lines...) Expand all
159 set _contentType(ContentType value) { 159 set _contentType(ContentType value) {
160 headers[HttpHeaders.CONTENT_TYPE] = value.toString(); 160 headers[HttpHeaders.CONTENT_TYPE] = value.toString();
161 } 161 }
162 162
163 /// Throw an error if this request has been finalized. 163 /// Throw an error if this request has been finalized.
164 void _checkFinalized() { 164 void _checkFinalized() {
165 if (!finalized) return; 165 if (!finalized) return;
166 throw new StateError("Can't modify a finalized Request."); 166 throw new StateError("Can't modify a finalized Request.");
167 } 167 }
168 } 168 }
OLDNEW
« no previous file with comments | « no previous file | pkg/http/lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698