fable 3.0.56 → 3.0.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fable",
3
- "version": "3.0.56",
3
+ "version": "3.0.57",
4
4
  "description": "An entity behavior management and API bundling library.",
5
5
  "main": "source/Fable.js",
6
6
  "scripts": {
@@ -55,6 +55,7 @@
55
55
  "async.eachlimit": "^0.5.2",
56
56
  "async.waterfall": "^0.5.2",
57
57
  "cachetrax": "^1.0.3",
58
+ "cookie": "^0.5.0",
58
59
  "data-arithmatic": "^1.0.7",
59
60
  "fable-log": "^3.0.10",
60
61
  "fable-serviceproviderbase": "^3.0.5",
@@ -1,6 +1,7 @@
1
1
  const libFableServiceBase = require('../Fable-ServiceManager.js').ServiceProviderBase;
2
2
 
3
3
  const libSimpleGet = require('simple-get');
4
+ const libCookie = require('cookie');
4
5
 
5
6
  class FableServiceRestClient extends libFableServiceBase
6
7
  {
@@ -18,15 +19,32 @@ class FableServiceRestClient extends libFableServiceBase
18
19
 
19
20
  this.serviceType = 'RestClient';
20
21
 
22
+ this.cookie = false;
23
+
21
24
  // This is a function that can be overridden, to allow the management
22
25
  // of the request options before they are passed to the request library.
23
26
  this.prepareRequestOptions = (pOptions) => { return pOptions; };
24
27
  }
25
28
 
29
+ prepareCookies(pRequestOptions)
30
+ {
31
+ if (this.cookie)
32
+ {
33
+ if (!pRequestOptions.hasOwnProperty('headers'))
34
+ {
35
+ pRequestOptions.headers = {};
36
+ }
37
+ let tmpCookieKey = Object.keys(this.cookie);
38
+ pRequestOptions.headers.cookie = libCookie.serialize(tmpCookieKey, this.cookie[tmpCookieKey]);
39
+ }
40
+ return pRequestOptions;
41
+ }
42
+
26
43
  preRequest(pOptions)
27
44
  {
28
45
  // Validate the options object
29
- return this.prepareRequestOptions(pOptions);
46
+ let tmpOptions = this.prepareCookies(pOptions);
47
+ return this.prepareRequestOptions(tmpOptions);
30
48
  }
31
49
 
32
50
  executeChunkedRequest(pOptions, fCallback)