no luck with sock proxies

This commit is contained in:
Bojan Kucera 2025-06-07 22:49:03 -04:00
parent a7cca4d4a1
commit 0eeb893d0f
5 changed files with 98 additions and 61 deletions

View file

@ -144,22 +144,25 @@ export class HttpClient {
* Got implementation (simplified for SOCKS proxies)
*/
private async gotRequest<T>(config: RequestConfig, signal: AbortSignal): Promise<HttpResponse<T>> {
try {
const options = this.buildGotOptions(config, signal);
const response = await got(config.url, options);
return this.parseGotResponse<T>(response);
} catch (error) {
// Handle both AbortSignal timeout and Got-specific timeout errors
if (signal.aborted) {
throw new HttpError(`Request timeout`);
if(config.proxy) {
try {
const gotClient = await ProxyManager.createGotInstance(config.proxy);
const response = await gotClient.get(config.url);
return this.parseGotResponse<T>(response);
} catch (error) {
console.error('Got request error:', error);
// Handle both AbortSignal timeout and Got-specific timeout errors
if (signal.aborted) {
throw new HttpError(`Request timeout`);
}
if ((error as any).name === 'TimeoutError') {
throw new HttpError(`Request timeout`);
}
throw new HttpError(`Request failed: ${(error as Error).message}`);
}
if ((error as any).name === 'TimeoutError') {
throw new HttpError(`Request timeout`);
}
throw new HttpError(`Request failed: ${(error as Error).message}`);
}else{
throw new HttpError(`Request failed: No proxy configured, use fetch instead`);
}
}
/**