Permalink
Browse files

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
  • Loading branch information...
victor-homyakov committed Dec 27, 2012
1 parent fe2b76f commit 2811f40a464b69274f407a3e39ce0e08584f39bd
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/prototype/ajax/request.js
@@ -259,8 +259,10 @@ Ajax.Request = Class.create(Ajax.Base, {
$H(extras).each(function(pair) { headers[pair.key] = pair.value });
}
+ // skip null or undefined values
for (var name in headers)
- this.transport.setRequestHeader(name, headers[name]);
+ if (headers[name] != null)
+ this.transport.setRequestHeader(name, headers[name]);
},
/**

0 comments on commit 2811f40

Please sign in to comment.