Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 2811f40a464b69274f407a3e39ce0e08584f39bd 1 parent fe2b76f
@victor-homyakov victor-homyakov authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/prototype/ajax/request.js
View
4 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]);
},
/**
Please sign in to comment.
Something went wrong with that request. Please try again.