aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/utils/requests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-01-29 08:37:25 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-02-11 09:13:02 +0100
commit092092969633bbcf6d4891a083ea497a7d5c3154 (patch)
tree69e82fe4f60c444cca216830e96afe143a9dac71 /shared/utils/requests
parent4348a27d252a3349bafa7ef4859c0e2cf060c255 (diff)
downloadPeerTube-092092969633bbcf6d4891a083ea497a7d5c3154.tar.gz
PeerTube-092092969633bbcf6d4891a083ea497a7d5c3154.tar.zst
PeerTube-092092969633bbcf6d4891a083ea497a7d5c3154.zip
Add hls support on server
Diffstat (limited to 'shared/utils/requests')
-rw-r--r--shared/utils/requests/requests.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/shared/utils/requests/requests.ts b/shared/utils/requests/requests.ts
index 77e9f6164..fc687c701 100644
--- a/shared/utils/requests/requests.ts
+++ b/shared/utils/requests/requests.ts
@@ -1,10 +1,17 @@
1import * as request from 'supertest' 1import * as request from 'supertest'
2import { buildAbsoluteFixturePath, root } from '../miscs/miscs' 2import { buildAbsoluteFixturePath, root } from '../miscs/miscs'
3import { isAbsolute, join } from 'path' 3import { isAbsolute, join } from 'path'
4import { parse } from 'url'
5
6function makeRawRequest (url: string, statusCodeExpected?: number) {
7 const { host, protocol, pathname } = parse(url)
8
9 return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, statusCodeExpected })
10}
4 11
5function makeGetRequest (options: { 12function makeGetRequest (options: {
6 url: string, 13 url: string,
7 path: string, 14 path?: string,
8 query?: any, 15 query?: any,
9 token?: string, 16 token?: string,
10 statusCodeExpected?: number, 17 statusCodeExpected?: number,
@@ -13,8 +20,7 @@ function makeGetRequest (options: {
13 if (!options.statusCodeExpected) options.statusCodeExpected = 400 20 if (!options.statusCodeExpected) options.statusCodeExpected = 400
14 if (options.contentType === undefined) options.contentType = 'application/json' 21 if (options.contentType === undefined) options.contentType = 'application/json'
15 22
16 const req = request(options.url) 23 const req = request(options.url).get(options.path)
17 .get(options.path)
18 24
19 if (options.contentType) req.set('Accept', options.contentType) 25 if (options.contentType) req.set('Accept', options.contentType)
20 if (options.token) req.set('Authorization', 'Bearer ' + options.token) 26 if (options.token) req.set('Authorization', 'Bearer ' + options.token)
@@ -164,5 +170,6 @@ export {
164 makePostBodyRequest, 170 makePostBodyRequest,
165 makePutBodyRequest, 171 makePutBodyRequest,
166 makeDeleteRequest, 172 makeDeleteRequest,
173 makeRawRequest,
167 updateAvatarRequest 174 updateAvatarRequest
168} 175}