diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-13 11:05:15 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | 41d1d075011174e73dccb74006181a92a618d7b4 (patch) | |
tree | 4dc1af0e266977f062cf9716837d04de1cdd628d /shared/extra-utils/requests/requests.ts | |
parent | 6c5065a011b099618681a37bd77eaa7bd3db752e (diff) | |
download | PeerTube-41d1d075011174e73dccb74006181a92a618d7b4.tar.gz PeerTube-41d1d075011174e73dccb74006181a92a618d7b4.tar.zst PeerTube-41d1d075011174e73dccb74006181a92a618d7b4.zip |
Introduce login command
Diffstat (limited to 'shared/extra-utils/requests/requests.ts')
-rw-r--r-- | shared/extra-utils/requests/requests.ts | 4 |
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) |