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

Side by Side Diff: sdk/lib/io/mime_multipart_parser.dart

Issue 12425004: Fix deprecation warnings in dart:io. Now completely warning free. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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
« no previous file with comments | « sdk/lib/io/http_utils.dart ('k') | sdk/lib/io/socket.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 7 /**
8 * Parser for MIME multipart types of data as described in RFC 2046 8 * Parser for MIME multipart types of data as described in RFC 2046
9 * section 5.1.1. The data to parse is supplied through the [:update:] 9 * section 5.1.1. The data to parse is supplied through the [:update:]
10 * method. As the data is parsed the following callbacks are called: 10 * method. As the data is parsed the following callbacks are called:
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 partEnd(false); 156 partEnd(false);
157 } 157 }
158 _state = _HEADER_START; 158 _state = _HEADER_START;
159 break; 159 break;
160 160
161 case _HEADER_START: 161 case _HEADER_START:
162 if (byte == _CharCode.CR) { 162 if (byte == _CharCode.CR) {
163 _state = _HEADER_ENDING; 163 _state = _HEADER_ENDING;
164 } else { 164 } else {
165 // Start of new header field. 165 // Start of new header field.
166 _headerField.addCharCode(_toLowerCase(byte)); 166 _headerField.writeCharCode(_toLowerCase(byte));
167 _state = _HEADER_FIELD; 167 _state = _HEADER_FIELD;
168 } 168 }
169 break; 169 break;
170 170
171 case _HEADER_FIELD: 171 case _HEADER_FIELD:
172 if (byte == _CharCode.COLON) { 172 if (byte == _CharCode.COLON) {
173 _state = _HEADER_VALUE_START; 173 _state = _HEADER_VALUE_START;
174 } else { 174 } else {
175 if (!_isTokenChar(byte)) { 175 if (!_isTokenChar(byte)) {
176 throw new MimeParserException("Invalid header field name"); 176 throw new MimeParserException("Invalid header field name");
177 } 177 }
178 _headerField.addCharCode(_toLowerCase(byte)); 178 _headerField.writeCharCode(_toLowerCase(byte));
179 } 179 }
180 break; 180 break;
181 181
182 case _HEADER_VALUE_START: 182 case _HEADER_VALUE_START:
183 if (byte == _CharCode.CR) { 183 if (byte == _CharCode.CR) {
184 _state = _HEADER_VALUE_FOLDING_OR_ENDING; 184 _state = _HEADER_VALUE_FOLDING_OR_ENDING;
185 } else if (byte != _CharCode.SP && byte != _CharCode.HT) { 185 } else if (byte != _CharCode.SP && byte != _CharCode.HT) {
186 // Start of new header value. 186 // Start of new header value.
187 _headerValue.addCharCode(byte); 187 _headerValue.writeCharCode(byte);
188 _state = _HEADER_VALUE; 188 _state = _HEADER_VALUE;
189 } 189 }
190 break; 190 break;
191 191
192 case _HEADER_VALUE: 192 case _HEADER_VALUE:
193 if (byte == _CharCode.CR) { 193 if (byte == _CharCode.CR) {
194 _state = _HEADER_VALUE_FOLDING_OR_ENDING; 194 _state = _HEADER_VALUE_FOLDING_OR_ENDING;
195 } else { 195 } else {
196 _headerValue.addCharCode(byte); 196 _headerValue.writeCharCode(byte);
197 } 197 }
198 break; 198 break;
199 199
200 case _HEADER_VALUE_FOLDING_OR_ENDING: 200 case _HEADER_VALUE_FOLDING_OR_ENDING:
201 _expect(byte, _CharCode.LF); 201 _expect(byte, _CharCode.LF);
202 _state = _HEADER_VALUE_FOLD_OR_END; 202 _state = _HEADER_VALUE_FOLD_OR_END;
203 break; 203 break;
204 204
205 case _HEADER_VALUE_FOLD_OR_END: 205 case _HEADER_VALUE_FOLD_OR_END:
206 if (byte == _CharCode.SP || byte == _CharCode.HT) { 206 if (byte == _CharCode.SP || byte == _CharCode.HT) {
207 _state = _HEADER_VALUE_START; 207 _state = _HEADER_VALUE_START;
208 } else { 208 } else {
209 String headerField = _headerField.toString(); 209 String headerField = _headerField.toString();
210 String headerValue =_headerValue.toString(); 210 String headerValue =_headerValue.toString();
211 if (headerReceived != null) { 211 if (headerReceived != null) {
212 headerReceived(headerField, headerValue); 212 headerReceived(headerField, headerValue);
213 } 213 }
214 _headerField.clear(); 214 _headerField = new StringBuffer();
215 _headerValue.clear(); 215 _headerValue = new StringBuffer();
216 if (byte == _CharCode.CR) { 216 if (byte == _CharCode.CR) {
217 _state = _HEADER_ENDING; 217 _state = _HEADER_ENDING;
218 } else { 218 } else {
219 // Start of new header field. 219 // Start of new header field.
220 _headerField.addCharCode(_toLowerCase(byte)); 220 _headerField.writeCharCode(_toLowerCase(byte));
221 _state = _HEADER_FIELD; 221 _state = _HEADER_FIELD;
222 } 222 }
223 } 223 }
224 break; 224 break;
225 225
226 case _HEADER_ENDING: 226 case _HEADER_ENDING:
227 _expect(byte, _CharCode.LF); 227 _expect(byte, _CharCode.LF);
228 if (headersComplete != null) headersComplete(); 228 if (headersComplete != null) headersComplete();
229 _state = _CONTENT; 229 _state = _CONTENT;
230 contentStartIndex = index + 1; 230 contentStartIndex = index + 1;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 Function partDataReceived; 324 Function partDataReceived;
325 Function partEnd; 325 Function partEnd;
326 } 326 }
327 327
328 328
329 class MimeParserException implements Exception { 329 class MimeParserException implements Exception {
330 const MimeParserException([String this.message = ""]); 330 const MimeParserException([String this.message = ""]);
331 String toString() => "MimeParserException: $message"; 331 String toString() => "MimeParserException: $message";
332 final String message; 332 final String message;
333 } 333 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http_utils.dart ('k') | sdk/lib/io/socket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698