diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-06 15:33:39 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:17 +0200 |
commit | 2d1ad5b96063d1e430ca99128a15e2e56cb614e0 (patch) | |
tree | 5f65def246ec7956cd6f8f2a252588591c994733 /shared/extra-utils/requests | |
parent | af971e06c620bd46a5aa64c8833364e7022b5e3d (diff) | |
download | PeerTube-2d1ad5b96063d1e430ca99128a15e2e56cb614e0.tar.gz PeerTube-2d1ad5b96063d1e430ca99128a15e2e56cb614e0.tar.zst PeerTube-2d1ad5b96063d1e430ca99128a15e2e56cb614e0.zip |
Move AP request in requests file
Diffstat (limited to 'shared/extra-utils/requests')
-rw-r--r-- | shared/extra-utils/requests/requests.ts | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts index 8c26a3699..3fbaa31d6 100644 --- a/shared/extra-utils/requests/requests.ts +++ b/shared/extra-utils/requests/requests.ts | |||
@@ -1,11 +1,11 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ |
2 | 2 | ||
3 | import * as request from 'supertest' | ||
4 | import { buildAbsoluteFixturePath, root } from '../miscs/miscs' | ||
5 | import { isAbsolute, join } from 'path' | 3 | import { isAbsolute, join } from 'path' |
6 | import { URL } from 'url' | ||
7 | import { decode } from 'querystring' | 4 | import { decode } from 'querystring' |
5 | import * as request from 'supertest' | ||
6 | import { URL } from 'url' | ||
8 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 7 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' |
8 | import { buildAbsoluteFixturePath, root } from '../miscs/miscs' | ||
9 | 9 | ||
10 | function get4KFileUrl () { | 10 | function get4KFileUrl () { |
11 | return 'https://download.cpy.re/peertube/4k_file.txt' | 11 | return 'https://download.cpy.re/peertube/4k_file.txt' |
@@ -154,6 +154,15 @@ function makeHTMLRequest (url: string, path: string) { | |||
154 | .expect(HttpStatusCode.OK_200) | 154 | .expect(HttpStatusCode.OK_200) |
155 | } | 155 | } |
156 | 156 | ||
157 | function makeActivityPubGetRequest (url: string, path: string, expectedStatus = HttpStatusCode.OK_200) { | ||
158 | return makeGetRequest({ | ||
159 | url, | ||
160 | path, | ||
161 | statusCodeExpected: expectedStatus, | ||
162 | accept: 'application/activity+json,text/html;q=0.9,\\*/\\*;q=0.8' | ||
163 | }) | ||
164 | } | ||
165 | |||
157 | function updateImageRequest (options: { | 166 | function updateImageRequest (options: { |
158 | url: string | 167 | url: string |
159 | path: string | 168 | path: string |
@@ -202,6 +211,7 @@ export { | |||
202 | makePutBodyRequest, | 211 | makePutBodyRequest, |
203 | makeDeleteRequest, | 212 | makeDeleteRequest, |
204 | makeRawRequest, | 213 | makeRawRequest, |
214 | makeActivityPubGetRequest, | ||
205 | unwrapBody, | 215 | unwrapBody, |
206 | unwrapText, | 216 | unwrapText, |
207 | updateImageRequest | 217 | updateImageRequest |