mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-29 15:59:39 +08:00
Summary: Updated networking and geolocation to use the new events system. Reviewed By: javache Differential Revision: D3339945 fbshipit-source-id: 01d307cf8a0aea3a404c87c6205132c42290abb1
48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
/**
|
|
* 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.
|
|
*
|
|
* @providesModule XMLHttpRequest
|
|
* @flow
|
|
*/
|
|
'use strict';
|
|
|
|
var FormData = require('FormData');
|
|
var RCTNetworking = require('RCTNetworking');
|
|
|
|
var XMLHttpRequestBase = require('XMLHttpRequestBase');
|
|
|
|
class XMLHttpRequest extends XMLHttpRequestBase {
|
|
sendImpl(
|
|
method: ?string,
|
|
url: ?string,
|
|
headers: Object,
|
|
data: any,
|
|
incrementalUpdates: boolean,
|
|
timeout: number,
|
|
): void {
|
|
if (typeof data === 'string') {
|
|
data = {string: data};
|
|
} else if (data instanceof FormData) {
|
|
data = {formData: data.getParts()};
|
|
}
|
|
RCTNetworking.sendRequest(
|
|
{
|
|
method,
|
|
url,
|
|
data,
|
|
headers,
|
|
incrementalUpdates,
|
|
timeout
|
|
},
|
|
this.didCreateRequest.bind(this)
|
|
);
|
|
}
|
|
}
|
|
|
|
module.exports = XMLHttpRequest;
|