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 10965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10976 * * 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]. | 10976 * * 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]. |
10977 * | 10977 * |
10978 * Note that requests for file:// URIs are only supported by Chrome extensions | 10978 * Note that requests for file:// URIs are only supported by Chrome extensions |
10979 * with appropriate permissions in their manifest. Requests to file:// URIs | 10979 * with appropriate permissions in their manifest. Requests to file:// URIs |
10980 * will also never fail- the Future will always complete successfully, even | 10980 * will also never fail- the Future will always complete successfully, even |
10981 * when the file cannot be found. | 10981 * when the file cannot be found. |
10982 * | 10982 * |
10983 * See also: [authorization headers](http://en.wikipedia.org/wiki/Basic_access
_authentication). | 10983 * See also: [authorization headers](http://en.wikipedia.org/wiki/Basic_access
_authentication). |
10984 */ | 10984 */ |
10985 static Future<HttpRequest> request(String url, | 10985 static Future<HttpRequest> request(String url, |
10986 {String method, bool withCredentials, String responseType, sendData, | 10986 {String method, bool withCredentials, String responseType, |
| 10987 String mimeType, Map<String, String> requestHeaders, sendData, |
10987 void onProgress(ProgressEvent e)}) { | 10988 void onProgress(ProgressEvent e)}) { |
10988 var completer = new Completer<HttpRequest>(); | 10989 var completer = new Completer<HttpRequest>(); |
10989 | 10990 |
10990 var xhr = new HttpRequest(); | 10991 var xhr = new HttpRequest(); |
10991 if (method == null) { | 10992 if (method == null) { |
10992 method = 'GET'; | 10993 method = 'GET'; |
10993 } | 10994 } |
10994 xhr.open(method, url, async: true); | 10995 xhr.open(method, url, async: true); |
10995 | 10996 |
10996 if (withCredentials != null) { | 10997 if (withCredentials != null) { |
10997 xhr.withCredentials = withCredentials; | 10998 xhr.withCredentials = withCredentials; |
10998 } | 10999 } |
10999 | 11000 |
11000 if (responseType != null) { | 11001 if (responseType != null) { |
11001 xhr.responseType = responseType; | 11002 xhr.responseType = responseType; |
11002 } | 11003 } |
11003 | 11004 |
| 11005 if (mimeType != null) { |
| 11006 xhr.overrideMimeType(mimeType); |
| 11007 } |
| 11008 |
| 11009 if (requestHeaders != null) { |
| 11010 requestHeaders.forEach((header, value) { |
| 11011 xhr.setRequestHeader(header, value); |
| 11012 }); |
| 11013 } |
| 11014 |
11004 if (onProgress != null) { | 11015 if (onProgress != null) { |
11005 xhr.onProgress.listen(onProgress); | 11016 xhr.onProgress.listen(onProgress); |
11006 } | 11017 } |
11007 | 11018 |
11008 xhr.onLoad.listen((e) { | 11019 xhr.onLoad.listen((e) { |
11009 // Note: file:// URIs have status of 0. | 11020 // Note: file:// URIs have status of 0. |
11010 if ((xhr.status >= 200 && xhr.status < 300) || | 11021 if ((xhr.status >= 200 && xhr.status < 300) || |
11011 xhr.status == 0 || xhr.status == 304) { | 11022 xhr.status == 0 || xhr.status == 304) { |
11012 completer.complete(xhr); | 11023 completer.complete(xhr); |
11013 } else { | 11024 } else { |
(...skipping 17636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
28650 } | 28661 } |
28651 | 28662 |
28652 _send(msg) { | 28663 _send(msg) { |
28653 _sendToHelperIsolate(msg, _sendPort); | 28664 _sendToHelperIsolate(msg, _sendPort); |
28654 } | 28665 } |
28655 } | 28666 } |
28656 | 28667 |
28657 get _pureIsolateTimerFactoryClosure => | 28668 get _pureIsolateTimerFactoryClosure => |
28658 ((int milliSeconds, void callback(Timer time), bool repeating) => | 28669 ((int milliSeconds, void callback(Timer time), bool repeating) => |
28659 new _PureIsolateTimer(milliSeconds, callback, repeating)); | 28670 new _PureIsolateTimer(milliSeconds, callback, repeating)); |
OLD | NEW |