Chromium Code Reviews| 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 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 Loading... | |
| 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 Loading... | |
| 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 } |
| OLD | NEW |