OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import 'package:collection/collection.dart'; | 5 import 'package:collection/collection.dart'; |
6 import 'package:string_scanner/string_scanner.dart'; | 6 import 'package:string_scanner/string_scanner.dart'; |
7 | 7 |
8 import 'case_insensitive_map.dart'; | 8 import 'case_insensitive_map.dart'; |
9 import 'scan.dart'; | 9 import 'scan.dart'; |
10 import 'utils.dart'; | 10 import 'utils.dart'; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 return wrapFormatException("media type", mediaType, () { | 46 return wrapFormatException("media type", mediaType, () { |
47 var scanner = new StringScanner(mediaType); | 47 var scanner = new StringScanner(mediaType); |
48 scanner.scan(whitespace); | 48 scanner.scan(whitespace); |
49 scanner.expect(token); | 49 scanner.expect(token); |
50 var type = scanner.lastMatch[0]; | 50 var type = scanner.lastMatch[0]; |
51 scanner.expect('/'); | 51 scanner.expect('/'); |
52 scanner.expect(token); | 52 scanner.expect(token); |
53 var subtype = scanner.lastMatch[0]; | 53 var subtype = scanner.lastMatch[0]; |
54 scanner.scan(whitespace); | 54 scanner.scan(whitespace); |
55 | 55 |
56 var parameters = {}; | 56 var parameters = <String, String>{}; |
57 while (scanner.scan(';')) { | 57 while (scanner.scan(';')) { |
58 scanner.scan(whitespace); | 58 scanner.scan(whitespace); |
59 scanner.expect(token); | 59 scanner.expect(token); |
60 var attribute = scanner.lastMatch[0]; | 60 var attribute = scanner.lastMatch[0]; |
61 scanner.expect('='); | 61 scanner.expect('='); |
62 | 62 |
63 var value; | 63 var value; |
64 if (scanner.scan(token)) { | 64 if (scanner.scan(token)) { |
65 value = scanner.lastMatch[0]; | 65 value = scanner.lastMatch[0]; |
66 } else { | 66 } else { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 value.replaceAllMapped(_escapedChar, (match) => "\\" + match[0])) | 141 value.replaceAllMapped(_escapedChar, (match) => "\\" + match[0])) |
142 ..write('"'); | 142 ..write('"'); |
143 } else { | 143 } else { |
144 buffer.write(value); | 144 buffer.write(value); |
145 } | 145 } |
146 }); | 146 }); |
147 | 147 |
148 return buffer.toString(); | 148 return buffer.toString(); |
149 } | 149 } |
150 } | 150 } |
OLD | NEW |