aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/requests
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/requests')
-rw-r--r--shared/extra-utils/requests/requests.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts
index f9d112aca..c5ee63e05 100644
--- a/shared/extra-utils/requests/requests.ts
+++ b/shared/extra-utils/requests/requests.ts
@@ -27,6 +27,7 @@ function makeGetRequest (options: {
27 range?: string 27 range?: string
28 redirects?: number 28 redirects?: number
29 accept?: string 29 accept?: string
30 host?: string
30}) { 31}) {
31 if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400 32 if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400
32 if (options.contentType === undefined) options.contentType = 'application/json' 33 if (options.contentType === undefined) options.contentType = 'application/json'
@@ -38,6 +39,7 @@ function makeGetRequest (options: {
38 if (options.query) req.query(options.query) 39 if (options.query) req.query(options.query)
39 if (options.range) req.set('Range', options.range) 40 if (options.range) req.set('Range', options.range)
40 if (options.accept) req.set('Accept', options.accept) 41 if (options.accept) req.set('Accept', options.accept)
42 if (options.host) req.set('Host', options.host)
41 if (options.redirects) req.redirects(options.redirects) 43 if (options.redirects) req.redirects(options.redirects)
42 44
43 return req.expect(options.statusCodeExpected) 45 return req.expect(options.statusCodeExpected)
@@ -113,6 +115,7 @@ function makePostBodyRequest (options: {
113 path: string 115 path: string
114 token?: string 116 token?: string
115 fields?: { [ fieldName: string ]: any } 117 fields?: { [ fieldName: string ]: any }
118 type?: string
116 statusCodeExpected?: HttpStatusCode 119 statusCodeExpected?: HttpStatusCode
117}) { 120}) {
118 if (!options.fields) options.fields = {} 121 if (!options.fields) options.fields = {}
@@ -123,6 +126,7 @@ function makePostBodyRequest (options: {
123 .set('Accept', 'application/json') 126 .set('Accept', 'application/json')
124 127
125 if (options.token) req.set('Authorization', 'Bearer ' + options.token) 128 if (options.token) req.set('Authorization', 'Bearer ' + options.token)
129 if (options.type) req.type(options.type)
126 130
127 return req.send(options.fields) 131 return req.send(options.fields)
128 .expect(options.statusCodeExpected) 132 .expect(options.statusCodeExpected)