| 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.ASCII) |
| 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, "form", result); |
| 126 }); |
| 127 |
| 113 default: | 128 default: |
| 114 break; | 129 break; |
| 115 } | 130 } |
| 116 break; | 131 break; |
| 117 | 132 |
| 118 case "multipart": | 133 case "multipart": |
| 119 switch (contentType.subType) { | 134 switch (contentType.subType) { |
| 120 case "form-data": | 135 case "form-data": |
| 121 return asFormData(); | 136 return asFormData(); |
| 122 | 137 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 _HttpClientResponseBody(HttpClientResponse response, HttpBody body) | 186 _HttpClientResponseBody(HttpClientResponse response, HttpBody body) |
| 172 : super(body.contentType, body.type, body.body), | 187 : super(body.contentType, body.type, body.body), |
| 173 this.response = response; | 188 this.response = response; |
| 174 | 189 |
| 175 int get statusCode => response.statusCode; | 190 int get statusCode => response.statusCode; |
| 176 | 191 |
| 177 String get reasonPhrase => response.reasonPhrase; | 192 String get reasonPhrase => response.reasonPhrase; |
| 178 | 193 |
| 179 HttpHeaders get headers => response.headers; | 194 HttpHeaders get headers => response.headers; |
| 180 } | 195 } |
| OLD | NEW |