forked from hibas123/SecureFileWrapper
adding no cache header
This commit is contained in:
parent
14ac8cd5d5
commit
33353e3136
19
index.js
19
index.js
@ -62,10 +62,18 @@ var SecureFile = /** @class */ (function () {
|
|||||||
}
|
}
|
||||||
SecureFile.prototype.getCode = function () {
|
SecureFile.prototype.getCode = function () {
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
var code_res, code, r;
|
var myHeaders, myInit, code_res, code, r;
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
switch (_a.label) {
|
switch (_a.label) {
|
||||||
case 0: return [4 /*yield*/, fetch(this.Server + "/code?username=" + this.Username)];
|
case 0:
|
||||||
|
myHeaders = new Headers();
|
||||||
|
myHeaders.append('pragma', 'no-cache');
|
||||||
|
myHeaders.append('cache-control', 'no-cache');
|
||||||
|
myInit = {
|
||||||
|
method: 'GET',
|
||||||
|
headers: myHeaders,
|
||||||
|
};
|
||||||
|
return [4 /*yield*/, fetch(this.Server + "/code?username=" + this.Username, myInit)];
|
||||||
case 1:
|
case 1:
|
||||||
code_res = _a.sent();
|
code_res = _a.sent();
|
||||||
statusParser(code_res);
|
statusParser(code_res);
|
||||||
@ -80,7 +88,7 @@ var SecureFile = /** @class */ (function () {
|
|||||||
};
|
};
|
||||||
SecureFile.prototype.makeRequest = function (endpoint, method, query, body) {
|
SecureFile.prototype.makeRequest = function (endpoint, method, query, body) {
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
var code, query_str, first, key;
|
var code, query_str, first, key, myHeaders;
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
switch (_a.label) {
|
switch (_a.label) {
|
||||||
case 0: return [4 /*yield*/, this.getCode()];
|
case 0: return [4 /*yield*/, this.getCode()];
|
||||||
@ -96,7 +104,10 @@ var SecureFile = /** @class */ (function () {
|
|||||||
query_str += encodeURIComponent(key) + "=" + encodeURIComponent(query[key]);
|
query_str += encodeURIComponent(key) + "=" + encodeURIComponent(query[key]);
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
return [4 /*yield*/, fetch(this.Server + endpoint + query_str, { method: method, body: body })];
|
myHeaders = new Headers();
|
||||||
|
myHeaders.append('pragma', 'no-cache');
|
||||||
|
myHeaders.append('cache-control', 'no-cache');
|
||||||
|
return [4 /*yield*/, fetch(this.Server + endpoint + query_str, { method: method, body: body, headers: myHeaders })];
|
||||||
case 2: return [2 /*return*/, _a.sent()];
|
case 2: return [2 /*return*/, _a.sent()];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
17
index.ts
17
index.ts
@ -33,7 +33,16 @@ export default class SecureFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getCode() {
|
private async getCode() {
|
||||||
let code_res = await fetch(this.Server + "/code?username=" + this.Username);
|
var myHeaders = new Headers();
|
||||||
|
myHeaders.append('pragma', 'no-cache');
|
||||||
|
myHeaders.append('cache-control', 'no-cache');
|
||||||
|
|
||||||
|
var myInit = {
|
||||||
|
method: 'GET',
|
||||||
|
headers: myHeaders,
|
||||||
|
};
|
||||||
|
|
||||||
|
let code_res = await fetch(this.Server + "/code?username=" + this.Username, myInit);
|
||||||
statusParser(code_res);
|
statusParser(code_res);
|
||||||
//ToDo check status Codes
|
//ToDo check status Codes
|
||||||
let code = (await code_res.json()).code;
|
let code = (await code_res.json()).code;
|
||||||
@ -52,7 +61,11 @@ export default class SecureFile {
|
|||||||
query_str += encodeURIComponent(key) + "=" + encodeURIComponent(query[key]);
|
query_str += encodeURIComponent(key) + "=" + encodeURIComponent(query[key]);
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
return await fetch(this.Server + endpoint + query_str, { method: method, body: body });
|
var myHeaders = new Headers();
|
||||||
|
myHeaders.append('pragma', 'no-cache');
|
||||||
|
myHeaders.append('cache-control', 'no-cache');
|
||||||
|
|
||||||
|
return await fetch(this.Server + endpoint + query_str, { method: method, body: body, headers: myHeaders });
|
||||||
}
|
}
|
||||||
|
|
||||||
async test(): Promise<{ user: string, test: true }> {
|
async test(): Promise<{ user: string, test: true }> {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "secure-file-wrapper",
|
"name": "secure-file-wrapper",
|
||||||
"version": "1.0.6",
|
"version": "1.0.7",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
Loading…
Reference in New Issue
Block a user