@@ -7,9 +7,9 @@ import { Boom, badGateway } from '@hapi/boom';
7
7
import { join , dirname } from 'path' ;
8
8
import { fileURLToPath } from 'url' ;
9
9
import fs from 'fs' ;
10
+ import HttpClient from '@podium/http-client' ;
10
11
import * as utils from './utils.js' ;
11
12
import Response from './response.js' ;
12
- import HTTP from './http.js' ;
13
13
14
14
const currentDirectory = dirname ( fileURLToPath ( import . meta. url ) ) ;
15
15
@@ -24,7 +24,7 @@ const UA_STRING = `${pkg.name} ${pkg.version}`;
24
24
/**
25
25
* @typedef {object } PodletClientContentResolverOptions
26
26
* @property {string } clientName
27
- * @property {import('. /http.js ').default } [http]
27
+ * @property {import('@podium /http-client ').default } [http]
28
28
* @property {import('abslog').AbstractLoggerOptions } [logger]
29
29
*/
30
30
@@ -40,7 +40,11 @@ export default class PodletClientContentResolver {
40
40
*/
41
41
// @ts -expect-error Deliberate default empty options for better error messages
42
42
constructor ( options = { } ) {
43
- this . #http = options . http || new HTTP ( ) ;
43
+ this . #http = options . http || new HttpClient ( {
44
+ timeout : options . timeout ,
45
+ throwOn400 : options . throwable ,
46
+ throwOn500 : options . throwable ,
47
+ } ) ;
44
48
const name = options . clientName ;
45
49
this . #log = abslog ( options . logger ) ;
46
50
this . #metrics = new Metrics ( ) ;
@@ -158,11 +162,17 @@ export default class PodletClientContentResolver {
158
162
) ;
159
163
160
164
try {
165
+ const url = new URL ( uri )
161
166
const {
162
167
statusCode,
163
168
headers : hdrs ,
164
169
body,
165
- } = await this . #http. request ( uri , reqOptions ) ;
170
+ } = await this . #http. request ( {
171
+ origin : url . origin ,
172
+ path : url . pathname ,
173
+ method : reqOptions . method ,
174
+ throwable : reqOptions . throwable
175
+ } ) ;
166
176
167
177
// Remote responds but with an http error code
168
178
const resError = statusCode >= 400 ;
0 commit comments