OLD | NEW |
1 /// The Dart HTML library. | 1 /// The Dart HTML library. |
2 library dart.dom.html; | 2 library dart.dom.html; |
3 | 3 |
4 import 'dart:async'; | 4 import 'dart:async'; |
5 import 'dart:collection'; | 5 import 'dart:collection'; |
6 import 'dart:_collection-dev' hide Symbol; | 6 import 'dart:_collection-dev' hide Symbol; |
7 import 'dart:html_common'; | 7 import 'dart:html_common'; |
8 import 'dart:indexed_db'; | 8 import 'dart:indexed_db'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 import 'dart:json' as json; | 10 import 'dart:json' as json; |
(...skipping 10555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10566 * * If `Access-Control-Expose-Headers` has not been set to true, only a subse
t of all the response headers will be returned when calling [getAllRequestHeader
s]. | 10566 * * If `Access-Control-Expose-Headers` has not been set to true, only a subse
t of all the response headers will be returned when calling [getAllRequestHeader
s]. |
10567 * | 10567 * |
10568 * Note that requests for file:// URIs are only supported by Chrome extensions | 10568 * Note that requests for file:// URIs are only supported by Chrome extensions |
10569 * with appropriate permissions in their manifest. Requests to file:// URIs | 10569 * with appropriate permissions in their manifest. Requests to file:// URIs |
10570 * will also never fail- the Future will always complete successfully, even | 10570 * will also never fail- the Future will always complete successfully, even |
10571 * when the file cannot be found. | 10571 * when the file cannot be found. |
10572 * | 10572 * |
10573 * See also: [authorization headers](http://en.wikipedia.org/wiki/Basic_access
_authentication). | 10573 * See also: [authorization headers](http://en.wikipedia.org/wiki/Basic_access
_authentication). |
10574 */ | 10574 */ |
10575 static Future<HttpRequest> request(String url, | 10575 static Future<HttpRequest> request(String url, |
10576 {String method, bool withCredentials, String responseType, sendData, | 10576 {String method, bool withCredentials, String responseType, |
| 10577 String mimeType, Map<String, String> requestHeaders, sendData, |
10577 void onProgress(ProgressEvent e)}) { | 10578 void onProgress(ProgressEvent e)}) { |
10578 var completer = new Completer<HttpRequest>(); | 10579 var completer = new Completer<HttpRequest>(); |
10579 | 10580 |
10580 var xhr = new HttpRequest(); | 10581 var xhr = new HttpRequest(); |
10581 if (method == null) { | 10582 if (method == null) { |
10582 method = 'GET'; | 10583 method = 'GET'; |
10583 } | 10584 } |
10584 xhr.open(method, url, async: true); | 10585 xhr.open(method, url, async: true); |
10585 | 10586 |
10586 if (withCredentials != null) { | 10587 if (withCredentials != null) { |
10587 xhr.withCredentials = withCredentials; | 10588 xhr.withCredentials = withCredentials; |
10588 } | 10589 } |
10589 | 10590 |
10590 if (responseType != null) { | 10591 if (responseType != null) { |
10591 xhr.responseType = responseType; | 10592 xhr.responseType = responseType; |
10592 } | 10593 } |
10593 | 10594 |
| 10595 if (mimeType != null) { |
| 10596 xhr.overrideMimeType(mimeType); |
| 10597 } |
| 10598 |
| 10599 if (requestHeaders != null) { |
| 10600 requestHeaders.forEach((header, value) { |
| 10601 xhr.setRequestHeader(header, value); |
| 10602 }); |
| 10603 } |
| 10604 |
10594 if (onProgress != null) { | 10605 if (onProgress != null) { |
10595 xhr.onProgress.listen(onProgress); | 10606 xhr.onProgress.listen(onProgress); |
10596 } | 10607 } |
10597 | 10608 |
10598 xhr.onLoad.listen((e) { | 10609 xhr.onLoad.listen((e) { |
10599 // Note: file:// URIs have status of 0. | 10610 // Note: file:// URIs have status of 0. |
10600 if ((xhr.status >= 200 && xhr.status < 300) || | 10611 if ((xhr.status >= 200 && xhr.status < 300) || |
10601 xhr.status == 0 || xhr.status == 304) { | 10612 xhr.status == 0 || xhr.status == 304) { |
10602 completer.complete(xhr); | 10613 completer.complete(xhr); |
10603 } else { | 10614 } else { |
(...skipping 16331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
26935 _position = nextPosition; | 26946 _position = nextPosition; |
26936 return true; | 26947 return true; |
26937 } | 26948 } |
26938 _current = null; | 26949 _current = null; |
26939 _position = _array.length; | 26950 _position = _array.length; |
26940 return false; | 26951 return false; |
26941 } | 26952 } |
26942 | 26953 |
26943 T get current => _current; | 26954 T get current => _current; |
26944 } | 26955 } |
OLD | NEW |