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

Side by Side Diff: sdk/lib/io/http_body_impl.dart

Issue 14660009: Implement support for application/x-www-form-urlencoded' form data in HttpBodyHandler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | sdk/lib/io/http_multipart_form_data_impl.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 part of dart.io; 5 part of dart.io;
6 6
7 class _HttpBodyHandlerTransformer 7 class _HttpBodyHandlerTransformer
8 extends StreamEventTransformer<HttpRequest, HttpRequestBody> { 8 extends StreamEventTransformer<HttpRequest, HttpRequestBody> {
9 void handleData(HttpRequest request, EventSink<HttpRequestBody> sink) { 9 void handleData(HttpRequest request, EventSink<HttpRequestBody> sink) {
10 HttpBodyHandler.processRequest(request) 10 HttpBodyHandler.processRequest(request)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 return asText(Encoding.ASCII); 103 return asText(Encoding.ASCII);
104 104
105 case "application": 105 case "application":
106 switch (contentType.subType) { 106 switch (contentType.subType) {
107 case "json": 107 case "json":
108 return asText(Encoding.UTF_8) 108 return asText(Encoding.UTF_8)
109 .then((body) => new _HttpBody(contentType, 109 .then((body) => new _HttpBody(contentType,
110 "json", 110 "json",
111 JSON.parse(body.body))); 111 JSON.parse(body.body)));
112 112
113 case "x-www-form-urlencoded":
114 return asText(Encoding.UTF_8)
Søren Gjesse 2013/05/07 13:39:29 This might as well be ASCII, as all non-alphanumer
Anders Johnsen 2013/05/07 14:04:30 Done.
115 .then((body) {
116 var map = _HttpUtils.splitQueryString(body.body);
117 var result = {};
118 String parse(String s) {
119 return _HttpUtils.decodeHttpEntityString(
120 _HttpUtils.decodeUrlEncodedString(s));
121 }
122 for (var key in map.keys) {
123 result[parse(key)] = parse(map[key]);
124 }
125 return new _HttpBody(contentType,
Søren Gjesse 2013/05/07 13:39:29 Fits one line?
Anders Johnsen 2013/05/07 14:04:30 Done.
126 "form",
127 result);
128 });
129
113 default: 130 default:
114 break; 131 break;
115 } 132 }
116 break; 133 break;
117 134
118 case "multipart": 135 case "multipart":
119 switch (contentType.subType) { 136 switch (contentType.subType) {
120 case "form-data": 137 case "form-data":
121 return asFormData(); 138 return asFormData();
122 139
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 _HttpClientResponseBody(HttpClientResponse response, HttpBody body) 188 _HttpClientResponseBody(HttpClientResponse response, HttpBody body)
172 : super(body.contentType, body.type, body.body), 189 : super(body.contentType, body.type, body.body),
173 this.response = response; 190 this.response = response;
174 191
175 int get statusCode => response.statusCode; 192 int get statusCode => response.statusCode;
176 193
177 String get reasonPhrase => response.reasonPhrase; 194 String get reasonPhrase => response.reasonPhrase;
178 195
179 HttpHeaders get headers => response.headers; 196 HttpHeaders get headers => response.headers;
180 } 197 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/io/http_multipart_form_data_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698