OLD | NEW |
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 final Encoding _defaultEncoding; | 9 final Encoding _defaultEncoding; |
10 _HttpBodyHandlerTransformer(this._defaultEncoding); | 10 _HttpBodyHandlerTransformer(this._defaultEncoding); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 switch (contentType.subType) { | 113 switch (contentType.subType) { |
114 case "json": | 114 case "json": |
115 return asText(Encoding.UTF_8) | 115 return asText(Encoding.UTF_8) |
116 .then((body) => new _HttpBody(contentType, | 116 .then((body) => new _HttpBody(contentType, |
117 "json", | 117 "json", |
118 JSON.parse(body.body))); | 118 JSON.parse(body.body))); |
119 | 119 |
120 case "x-www-form-urlencoded": | 120 case "x-www-form-urlencoded": |
121 return asText(Encoding.ASCII) | 121 return asText(Encoding.ASCII) |
122 .then((body) { | 122 .then((body) { |
123 var map = _HttpUtils.splitQueryString( | 123 var map = Uri.splitQueryString(body.body, |
124 body.body, encoding: defaultEncoding); | 124 decode: (s) => _decodeString(s, defaultEncoding)); |
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 } |
129 return new _HttpBody(contentType, "form", result); | 129 return new _HttpBody(contentType, "form", result); |
130 }); | 130 }); |
131 | 131 |
132 default: | 132 default: |
133 break; | 133 break; |
134 } | 134 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |