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

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

Issue 18438005: Move MimeMultipartTransformer and HttpBodyHandler to mime and http_server packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove import. Created 7 years, 5 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 dart.io; 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);
11 11
12 void handleData(HttpRequest request, EventSink<HttpRequestBody> sink) { 12 void handleData(HttpRequest request, EventSink<HttpRequestBody> sink) {
13 _HttpBodyHandler.processRequest(request, _defaultEncoding) 13 _HttpBodyHandler.processRequest(request, _defaultEncoding)
14 .then(sink.add, onError: sink.addError); 14 .then(sink.add, onError: sink.addError);
15 } 15 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 break; 143 break;
144 } 144 }
145 break; 145 break;
146 146
147 default: 147 default:
148 break; 148 break;
149 } 149 }
150 150
151 return asBinary(); 151 return asBinary();
152 } 152 }
153
154 // Utility function to synchronously decode a list of bytes.
155 static String _decodeString(List<int> bytes,
156 [Encoding encoding = Encoding.UTF_8]) {
157 if (bytes.length == 0) return "";
158 var string;
159 var error;
160 var controller = new StreamController(sync: true);
161 controller.stream
162 .transform(new StringDecoder(encoding))
163 .listen((data) => string = data,
164 onError: (e) => error = e);
165 controller.add(bytes);
166 controller.close();
167 if (error != null) throw error;
168 assert(string != null);
169 return string;
170 }
153 } 171 }
154 172
155 class _HttpBodyFileUpload implements HttpBodyFileUpload { 173 class _HttpBodyFileUpload implements HttpBodyFileUpload {
156 final ContentType contentType; 174 final ContentType contentType;
157 final String filename; 175 final String filename;
158 final dynamic content; 176 final dynamic content;
159 _HttpBodyFileUpload(this.contentType, this.filename, this.content); 177 _HttpBodyFileUpload(this.contentType, this.filename, this.content);
160 } 178 }
161 179
162 class _HttpBody implements HttpBody { 180 class _HttpBody implements HttpBody {
(...skipping 27 matching lines...) Expand all
190 _HttpClientResponseBody(HttpClientResponse response, HttpBody body) 208 _HttpClientResponseBody(HttpClientResponse response, HttpBody body)
191 : super(body.contentType, body.type, body.body), 209 : super(body.contentType, body.type, body.body),
192 this.response = response; 210 this.response = response;
193 211
194 int get statusCode => response.statusCode; 212 int get statusCode => response.statusCode;
195 213
196 String get reasonPhrase => response.reasonPhrase; 214 String get reasonPhrase => response.reasonPhrase;
197 215
198 HttpHeaders get headers => response.headers; 216 HttpHeaders get headers => response.headers;
199 } 217 }
OLDNEW
« no previous file with comments | « pkg/http_server/lib/src/http_body.dart ('k') | pkg/http_server/lib/src/http_multipart_form_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698