@hkdigital/lib-sveltekit 0.0.68 → 0.0.70
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.
@@ -85,12 +85,4 @@ export function httpPost({ url, body, headers, requestHandler, timeoutMs }: stri
|
|
85
85
|
* @returns {Promise<*>} responsePromise
|
86
86
|
*/
|
87
87
|
export function httpRequest({ method, url, urlSearchParams, body, headers, requestHandler, timeoutMs }: string | URL): Promise<any>;
|
88
|
-
/**
|
89
|
-
* Get the response size from the content-length response header
|
90
|
-
*
|
91
|
-
* @param {Response} response
|
92
|
-
*
|
93
|
-
* @returns {number} response size or 0 if unknown
|
94
|
-
*/
|
95
|
-
export function getResponseSize(response: Response): number;
|
96
88
|
export type requestHandler = (controller: AbortController, abort: (reason?: Error) => void, timeout: (delayMs: number) => void) => any;
|
@@ -268,20 +268,3 @@ export async function httpRequest({
|
|
268
268
|
// response promise
|
269
269
|
return promise;
|
270
270
|
}
|
271
|
-
|
272
|
-
/**
|
273
|
-
* Get the response size from the content-length response header
|
274
|
-
*
|
275
|
-
* @param {Response} response
|
276
|
-
*
|
277
|
-
* @returns {number} response size or 0 if unknown
|
278
|
-
*/
|
279
|
-
export function getResponseSize(response) {
|
280
|
-
const sizeStr = response.headers.get(CONTENT_LENGTH);
|
281
|
-
|
282
|
-
if (!sizeStr) {
|
283
|
-
return 0;
|
284
|
-
}
|
285
|
-
|
286
|
-
return parseInt(sizeStr, 10);
|
287
|
-
}
|
@@ -8,6 +8,14 @@
|
|
8
8
|
* @throws {Error} internal server error
|
9
9
|
*/
|
10
10
|
export function expectResponseOk(response: object, url: string): Promise<void>;
|
11
|
+
/**
|
12
|
+
* Get the response size from the content-length response header
|
13
|
+
*
|
14
|
+
* @param {Response} response
|
15
|
+
*
|
16
|
+
* @returns {number} response size or 0 if unknown
|
17
|
+
*/
|
18
|
+
export function getResponseSize(response: Response): number;
|
11
19
|
/**
|
12
20
|
* Wait for a response and check if the response is ok
|
13
21
|
*
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ResponseError } from '../../constants/errors/index.js';
|
2
2
|
import * as expect from '../expect/index.js';
|
3
3
|
|
4
|
-
import { WWW_AUTHENTICATE } from '../../constants/http/headers.js';
|
4
|
+
import { WWW_AUTHENTICATE, CONTENT_LENGTH } from '../../constants/http/headers.js';
|
5
5
|
|
6
6
|
import { href } from './url.js';
|
7
7
|
|
@@ -62,6 +62,23 @@ export async function expectResponseOk(response, url) {
|
|
62
62
|
);
|
63
63
|
}
|
64
64
|
|
65
|
+
/**
|
66
|
+
* Get the response size from the content-length response header
|
67
|
+
*
|
68
|
+
* @param {Response} response
|
69
|
+
*
|
70
|
+
* @returns {number} response size or 0 if unknown
|
71
|
+
*/
|
72
|
+
export function getResponseSize(response) {
|
73
|
+
const sizeStr = response.headers.get(CONTENT_LENGTH);
|
74
|
+
|
75
|
+
if (!sizeStr) {
|
76
|
+
return 0;
|
77
|
+
}
|
78
|
+
|
79
|
+
return parseInt(sizeStr, 10);
|
80
|
+
}
|
81
|
+
|
65
82
|
/**
|
66
83
|
* Wait for a response and check if the response is ok
|
67
84
|
*
|