Skip to content

Commit

Permalink
Merge pull request #1 from TomaszQr/master_1
Browse files Browse the repository at this point in the history
Improved add token to request
  • Loading branch information
mariuszkrzaczkowski authored May 23, 2018
2 parents abd5b14 + c4324c4 commit 3effa53
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/Csrf.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ CsrfMagic.prototype = {

send: function (data) {
if (!this.csrf_isPost) return this.csrf_send(data);
prepend = csrfMagicName + '=' + csrfMagicToken + '&';
// XXX: Removed to eliminate 'Refused to set unsafe header "Content-length" ' errors in modern browsers
// if (this.csrf_purportedLength === undefined) {
// this.csrf_setRequestHeader("Content-length", this.csrf_purportedLength + prepend.length);
// delete this.csrf_purportedLength;
// }
delete this.csrf_isPost;
return this.csrf_send(prepend + data);
if(data instanceof FormData) {
data.append(csrfMagicName, csrfMagicToken);
return this.csrf_send(data);
} else {
return this.csrf_send(csrfMagicName + '=' + csrfMagicToken + '&' + data);
}
},
csrf_send: function (data) {
return this.csrf.send(data);
Expand Down
2 changes: 1 addition & 1 deletion src/Csrf.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3effa53

Please sign in to comment.