aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-03-09 14:01:44 +0100
committerChocobozzz <me@florianbigard.com>2021-03-24 18:18:40 +0100
commitb5c361089f03f4d459fa1cdc49ff66dee736af12 (patch)
tree0ac886c8358e890dc45b3e53f7b0da2e1c979122 /server/helpers
parent2d5a469427641e5ace48ad487bae2f35d9759107 (diff)
downloadPeerTube-b5c361089f03f4d459fa1cdc49ff66dee736af12.tar.gz
PeerTube-b5c361089f03f4d459fa1cdc49ff66dee736af12.tar.zst
PeerTube-b5c361089f03f4d459fa1cdc49ff66dee736af12.zip
Fix 404 AP status codes
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/requests.ts18
1 files changed, 12 insertions, 6 deletions
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts
index aee8f6673..5eb69486d 100644
--- a/server/helpers/requests.ts
+++ b/server/helpers/requests.ts
@@ -1,5 +1,5 @@
1import { createWriteStream, remove } from 'fs-extra' 1import { createWriteStream, remove } from 'fs-extra'
2import got, { CancelableRequest, Options as GotOptions } from 'got' 2import got, { CancelableRequest, Options as GotOptions, RequestError } from 'got'
3import { join } from 'path' 3import { join } from 'path'
4import { CONFIG } from '../initializers/config' 4import { CONFIG } from '../initializers/config'
5import { ACTIVITY_PUB, PEERTUBE_VERSION, WEBSERVER } from '../initializers/constants' 5import { ACTIVITY_PUB, PEERTUBE_VERSION, WEBSERVER } from '../initializers/constants'
@@ -7,6 +7,11 @@ import { pipelinePromise } from './core-utils'
7import { processImage } from './image-utils' 7import { processImage } from './image-utils'
8import { logger } from './logger' 8import { logger } from './logger'
9 9
10export interface PeerTubeRequestError extends Error {
11 statusCode?: number
12 responseBody?: any
13}
14
10const httpSignature = require('http-signature') 15const httpSignature = require('http-signature')
11 16
12type PeerTubeRequestOptions = { 17type PeerTubeRequestOptions = {
@@ -180,14 +185,15 @@ function buildGotOptions (options: PeerTubeRequestOptions) {
180 } 185 }
181} 186}
182 187
183function buildRequestError (error: any) { 188function buildRequestError (error: RequestError) {
184 const newError = new Error(error.message) 189 const newError: PeerTubeRequestError = new Error(error.message)
185 newError.name = error.name 190 newError.name = error.name
186 newError.stack = error.stack 191 newError.stack = error.stack
187 192
188 if (error.response?.body) { 193 if (error.response) {
189 error.responseBody = error.response.body 194 newError.responseBody = error.response.body
195 newError.statusCode = error.response.statusCode
190 } 196 }
191 197
192 return error 198 return newError
193} 199}