Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XMLHttpRequest] Uppercases the method variable to sanitize the string #6956

Closed
wants to merge 1 commit into from

Conversation

dsibiski
Copy link
Contributor

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

Fixes: #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.

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' }));

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

Fixes: facebook#6855
@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @nicklockwood, @davidaurelio and @lexs to be potential reviewers.

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Apr 13, 2016
@davidaurelio
Copy link
Contributor

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to Phabricator to review.

@ghost ghost closed this in 4450d78 Apr 13, 2016
zebulgar pushed a commit to nightingale/react-native that referenced this pull request Jun 18, 2016
Summary:This prevents possible developer errors when using 'post' or 'put' instead of 'POST' and 'PUT'.

Fixes: facebook#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 facebook#6956

Differential Revision: D3173467

Pulled By: davidaurelio

fb-gh-sync-id: add90e9f31cd4f548547a3f85267a782ae74a89c
fbshipit-source-id: add90e9f31cd4f548547a3f85267a782ae74a89c
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XMLHttpRequest PUT Error (Android)
3 participants