Skip to content

Commit 4b9fe6f

Browse files
Merge pull request #88 from victor-homyakov/patch-32
Don’t send Ajax headers whose values are `null`. This allows end users to opt out of `X-Requested-With` and `X-Prototype-Version` by explicitly setting them to `null`. (Use case: making a CORS Ajax request without a preflight request.)
2 parents fe2b76f + 2811f40 commit 4b9fe6f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/prototype/ajax/request.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,10 @@ Ajax.Request = Class.create(Ajax.Base, {
259259
$H(extras).each(function(pair) { headers[pair.key] = pair.value });
260260
}
261261

262+
// skip null or undefined values
262263
for (var name in headers)
263-
this.transport.setRequestHeader(name, headers[name]);
264+
if (headers[name] != null)
265+
this.transport.setRequestHeader(name, headers[name]);
264266
},
265267

266268
/**

0 commit comments

Comments
 (0)