Permalink
Browse files

fixes #38 - gives access to xhr request headers via the .get api for…

… browser env
  • Loading branch information...
DimitarChristoff committed Feb 3, 2013
1 parent e5b850a commit 9c5d8637a399eae1c83cdeedb66858b2a28cc6b7
Showing with 11 additions and 2 deletions.
  1. +11 −2 text.js
View
13 text.js
@@ -251,10 +251,19 @@ define(['module'], function (module) {
};
} else if (masterConfig.env === 'xhr' || (!masterConfig.env &&
text.createXhr())) {
- text.get = function (url, callback, errback) {
- var xhr = text.createXhr();
+ text.get = function (url, callback, errback, headers) {
+ var xhr = text.createXhr(), header;
xhr.open('GET', url, true);
+ //Allow plugins direct access to xhr headers
+ if (headers) {
+ for (header in headers) {
+ if (headers.hasOwnProperty(header)) {
+ xhr.setRequestHeader(header.toLowerCase(), headers[header]);
+ }
+ }
+ }
+
//Allow overrides specified in config
if (masterConfig.onXhr) {
masterConfig.onXhr(xhr, url);

0 comments on commit 9c5d863

Please sign in to comment.