2
0
Fork 0

Added request headers

This commit is contained in:
Willem 2016-01-21 22:41:56 +01:00
parent 9b40d0e78a
commit e65d557b4f
3 changed files with 15 additions and 8 deletions

View file

@ -88,6 +88,7 @@ A javascript library providing server defined loading of assets for a single pag
* server.assets = The server path to the assets resources definition file, is required (default: null) * server.assets = The server path to the assets resources definition file, is required (default: null)
* server.timeout = The timeout to download the server resources. (default: 4096) * server.timeout = The timeout to download the server resources. (default: 4096)
* server.flag = The window flag which is set when the server.url is know. (default: 'FFServerUrl') * server.flag = The window flag which is set when the server.url is know. (default: 'FFServerUrl')
* server.header.request = An key value object with the request headers. (default: {'X-FFSpaLoader': 'sync'})
* question.transport = The transport to prefix the server.url with. (default: 'http://') * question.transport = The transport to prefix the server.url with. (default: 'http://')
* question.title = The question ui title. (default: 'Server') * question.title = The question ui title. (default: 'Server')
* question.text = The question ui text. (default: 'Please provide the server name;') * question.text = The question ui text. (default: 'Please provide the server name;')
@ -155,7 +156,7 @@ A javascript library providing server defined loading of assets for a single pag
## Todo ## Todo
* test in production * test in production
* Server header set+check support * Server header check support
* Redo css(?divs) of server question * Redo css(?divs) of server question
* Add table+instance websql options so it can also be used in application code. * Add table+instance websql options so it can also be used in application code.
* Add more tests * Add more tests
@ -175,7 +176,7 @@ Add unit tests for any new or changed functionality. Lint and test your code.
* Added question.validate.[min|max|regex].value|message options. * Added question.validate.[min|max|regex].value|message options.
* Strip question value to hostname+port before use and validating. * Strip question value to hostname+port before use and validating.
* Allow user upgrade to https in question input from default of transport option. * Allow user upgrade to https in question input from default of transport option.
* Added request headers setting.
### 0.0.4 ### 0.0.4
* Added auto cache clean code * Added auto cache clean code

View file

@ -69,10 +69,10 @@
timeout: 4096, timeout: 4096,
flag: 'FFServerUrl', flag: 'FFServerUrl',
header: { header: {
request: { // TODO: add header support request: {
'X-FFSpaLoader': '42' 'X-FFSpaLoader': 'sync'
}, },
response: { response: { // TODO: add header check support
} }
} }
}, },
@ -316,6 +316,12 @@
httpRequest.ontimeout = function() { httpRequest.ontimeout = function() {
cb('timeout after '+options.server.timeout+' of url '+url); cb('timeout after '+options.server.timeout+' of url '+url);
}; };
var headerKeys = Object.keys(options.server.header.request);
for (var headerKeyIdx in headerKeys) {
var headerKey = headerKeys[headerKeyIdx];
var headerValue = options.server.header.request[headerKey];
httpRequest.setRequestHeader(headerKey,headerValue);
}
httpRequest.send(); httpRequest.send();
}; };