Skip to content

Commit b6cc554

Browse files
committed
allow custom headers
1 parent 3af1b9d commit b6cc554

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

dist/please.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* please-ajax - A small and modern AJAX library.
3-
* @version v1.0.6
3+
* @version v1.0.7
44
* @author Dan Reeves <[email protected]> (http://danreev.es/)
55
* @link https://github.com/fffunction/please
66
* @license MIT
@@ -33,6 +33,7 @@
3333
var options = {
3434
fileForm: opts.fileForm || false,
3535
promise: opts.promise || false,
36+
headers: opts.headers || {},
3637
success: opts.success || function () {},
3738
error: opts.error || function () {},
3839
loadstart: opts.loadstart || function () {},
@@ -107,6 +108,11 @@
107108
}
108109
};
109110
}
111+
for (var header in options.headers) {
112+
if (options.headers.hasOwnProperty(header)) {
113+
request.setRequestHeader(header, options.headers[header]);
114+
}
115+
}
110116
if (!!root.Promise && options.promise) {
111117
return new Promise(function(resolve, reject) {
112118
request.onload = function() {

dist/please.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "please-ajax",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "A small and modern AJAX library.",
55
"main": "dist/please.js",
66
"scripts": {

src/please.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
var options = {
2727
fileForm: opts.fileForm || false,
2828
promise: opts.promise || false,
29+
headers: opts.headers || {},
2930
success: opts.success || function () {},
3031
error: opts.error || function () {},
3132
loadstart: opts.loadstart || function () {},
@@ -100,6 +101,11 @@
100101
}
101102
};
102103
}
104+
for (var header in options.headers) {
105+
if (options.headers.hasOwnProperty(header)) {
106+
request.setRequestHeader(header, options.headers[header]);
107+
}
108+
}
103109
if (!!root.Promise && options.promise) {
104110
return new Promise(function(resolve, reject) {
105111
request.onload = function() {

0 commit comments

Comments
 (0)