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

Side by Side Diff: pkg/http_server/lib/src/http_body_impl.dart

Issue 23596007: Remove usage of dart:json. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. 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
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 http_server; 5 part of http_server;
6 6
7 class _HttpBodyHandlerTransformer 7 class _HttpBodyHandlerTransformer
8 extends StreamEventTransformer<HttpRequest, HttpRequestBody> { 8 extends StreamEventTransformer<HttpRequest, HttpRequestBody> {
9 final Encoding _defaultEncoding; 9 final Encoding _defaultEncoding;
10 _HttpBodyHandlerTransformer(this._defaultEncoding); 10 _HttpBodyHandlerTransformer(this._defaultEncoding);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 switch (contentType.primaryType) { 108 switch (contentType.primaryType) {
109 case "text": 109 case "text":
110 return asText(ASCII); 110 return asText(ASCII);
111 111
112 case "application": 112 case "application":
113 switch (contentType.subType) { 113 switch (contentType.subType) {
114 case "json": 114 case "json":
115 return asText(UTF8) 115 return asText(UTF8)
116 .then((body) => new _HttpBody(contentType, 116 .then((body) => new _HttpBody(contentType,
117 "json", 117 "json",
118 JSON.parse(body.body))); 118 JSON.decode(body.body)));
119 119
120 case "x-www-form-urlencoded": 120 case "x-www-form-urlencoded":
121 return asText(ASCII) 121 return asText(ASCII)
122 .then((body) { 122 .then((body) {
123 var map = Uri.splitQueryString(body.body, 123 var map = Uri.splitQueryString(body.body,
124 decode: (s) => defaultEncoding.decode(s)); 124 decode: (s) => defaultEncoding.decode(s));
125 var result = {}; 125 var result = {};
126 for (var key in map.keys) { 126 for (var key in map.keys) {
127 result[key] = map[key]; 127 result[key] = map[key];
128 } 128 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 _HttpClientResponseBody(HttpClientResponse response, HttpBody body) 190 _HttpClientResponseBody(HttpClientResponse response, HttpBody body)
191 : super(body.contentType, body.type, body.body), 191 : super(body.contentType, body.type, body.body),
192 this.response = response; 192 this.response = response;
193 193
194 int get statusCode => response.statusCode; 194 int get statusCode => response.statusCode;
195 195
196 String get reasonPhrase => response.reasonPhrase; 196 String get reasonPhrase => response.reasonPhrase;
197 197
198 HttpHeaders get headers => response.headers; 198 HttpHeaders get headers => response.headers;
199 } 199 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698