aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/utils/requests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-02-07 15:08:19 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-02-11 09:13:02 +0100
commit4c280004ce62bf11ddb091854c28f1e1d54a54d6 (patch)
tree1899fff4ef18f8663a865997d5d06119b2149319 /shared/utils/requests
parent6ec0b75beb9c8bcd84e178912319913b91830da2 (diff)
downloadPeerTube-4c280004ce62bf11ddb091854c28f1e1d54a54d6.tar.gz
PeerTube-4c280004ce62bf11ddb091854c28f1e1d54a54d6.tar.zst
PeerTube-4c280004ce62bf11ddb091854c28f1e1d54a54d6.zip
Use a single file instead of segments for HLS
Diffstat (limited to 'shared/utils/requests')
-rw-r--r--shared/utils/requests/requests.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/shared/utils/requests/requests.ts b/shared/utils/requests/requests.ts
index fc687c701..6b59e24fc 100644
--- a/shared/utils/requests/requests.ts
+++ b/shared/utils/requests/requests.ts
@@ -3,10 +3,10 @@ import { buildAbsoluteFixturePath, root } from '../miscs/miscs'
3import { isAbsolute, join } from 'path' 3import { isAbsolute, join } from 'path'
4import { parse } from 'url' 4import { parse } from 'url'
5 5
6function makeRawRequest (url: string, statusCodeExpected?: number) { 6function makeRawRequest (url: string, statusCodeExpected?: number, range?: string) {
7 const { host, protocol, pathname } = parse(url) 7 const { host, protocol, pathname } = parse(url)
8 8
9 return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, statusCodeExpected }) 9 return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, statusCodeExpected, range })
10} 10}
11 11
12function makeGetRequest (options: { 12function makeGetRequest (options: {
@@ -15,7 +15,8 @@ function makeGetRequest (options: {
15 query?: any, 15 query?: any,
16 token?: string, 16 token?: string,
17 statusCodeExpected?: number, 17 statusCodeExpected?: number,
18 contentType?: string 18 contentType?: string,
19 range?: string
19}) { 20}) {
20 if (!options.statusCodeExpected) options.statusCodeExpected = 400 21 if (!options.statusCodeExpected) options.statusCodeExpected = 400
21 if (options.contentType === undefined) options.contentType = 'application/json' 22 if (options.contentType === undefined) options.contentType = 'application/json'
@@ -25,6 +26,7 @@ function makeGetRequest (options: {
25 if (options.contentType) req.set('Accept', options.contentType) 26 if (options.contentType) req.set('Accept', options.contentType)
26 if (options.token) req.set('Authorization', 'Bearer ' + options.token) 27 if (options.token) req.set('Authorization', 'Bearer ' + options.token)
27 if (options.query) req.query(options.query) 28 if (options.query) req.query(options.query)
29 if (options.range) req.set('Range', options.range)
28 30
29 return req.expect(options.statusCodeExpected) 31 return req.expect(options.statusCodeExpected)
30} 32}