Uppercases the `method` variable to sanitize the string

Summary:This prevents possible developer errors when using 'post' or 'put' instead of 'POST' and 'PUT'.

Fixes: https://github.com/facebook/react-native/issues/6855

**Test plan:**

Previously, a `method put must not have a request body` error would be thrown when the method was in lowercase and a request body was indeed included.

With this fix and the following code (note the method name in all lowercase), the request is properly completed.

```javascript
const url = 'http://myurl.com';
const request = new XMLHttpRequest();

request.open('put', url);
request.setRequestHeader("Content-type","application/json");

request.onload = function() {
    console.log('onload');
};

request.onerror = function() {
    console.log('error');
};

request.send(JSON.stringify({ something: 'here' }));
```
Closes https://github.com/facebook/react-native/pull/6956

Differential Revision: D3173467

Pulled By: davidaurelio

fb-gh-sync-id: add90e9f31cd4f548547a3f85267a782ae74a89c
fbshipit-source-id: add90e9f31cd4f548547a3f85267a782ae74a89c
This commit is contained in:
Dave Sibiski 2016-04-13 06:47:29 -07:00 committed by Facebook Github Bot 4
parent 234142cdf7
commit 4450d789e0
1 changed files with 1 additions and 1 deletions

View File

@ -304,7 +304,7 @@ class XMLHttpRequestBase {
throw new Error('Cannot load an empty url');
}
this._reset();
this._method = method;
this._method = method.toUpperCase();
this._url = url;
this._aborted = false;
this.setReadyState(this.OPENED);