2015-01-30 01:10:49 +00:00
|
|
|
/**
|
2015-03-23 22:07:33 +00:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
2015-01-30 01:10:49 +00:00
|
|
|
*
|
|
|
|
* @providesModule XMLHttpRequest
|
|
|
|
* @flow
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2015-03-18 22:57:49 +00:00
|
|
|
var RCTDataManager = require('NativeModules').DataManager;
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2015-03-25 02:34:12 +00:00
|
|
|
var XMLHttpRequestBase = require('XMLHttpRequestBase');
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2015-03-25 02:34:12 +00:00
|
|
|
class XMLHttpRequest extends XMLHttpRequestBase {
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2015-03-25 02:34:12 +00:00
|
|
|
sendImpl(method: ?string, url: ?string, headers: Object, data: any): void {
|
2015-03-17 20:42:44 +00:00
|
|
|
RCTDataManager.queryData(
|
2015-01-30 01:10:49 +00:00
|
|
|
'http',
|
2015-04-10 08:33:10 +00:00
|
|
|
{
|
2015-05-26 20:29:41 +00:00
|
|
|
method: method,
|
|
|
|
url: url,
|
|
|
|
data: data,
|
|
|
|
headers: headers,
|
2015-04-10 08:33:10 +00:00
|
|
|
},
|
2015-06-01 15:28:31 +00:00
|
|
|
this.callback.bind(this)
|
2015-01-30 01:10:49 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-03-25 02:34:12 +00:00
|
|
|
abortImpl(): void {
|
2015-01-30 01:10:49 +00:00
|
|
|
console.warn(
|
|
|
|
'XMLHttpRequest: abort() cancels JS callbacks ' +
|
|
|
|
'but not native HTTP request.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = XMLHttpRequest;
|