Skip to content

Commit 2811f40

Browse files
author
Victor Homyakov
committed
Possibility to remove X-* headers for CORS request
`setRequestHeaders()` unconditionally adds specific headers to any request. This patch gives possibility to remove these headers in order to allow simple CORS request. Based on http://stackoverflow.com/questions/13814739/prototype-ajax-request-being-sent-as-options-rather-than-get-results-in-501-err and https://prototype.lighthouseapp.com/projects/8886/tickets/1590-ability-to-remove-headers-in-ajaxrequestsetrequestheaders-for-cors
1 parent fe2b76f commit 2811f40

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)