Skip to content

Commit

Permalink
trying something
Browse files Browse the repository at this point in the history
  • Loading branch information
eyalk007 committed Oct 16, 2024
1 parent 65c3e9f commit db1afe8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 52 deletions.
23 changes: 8 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"dist/**/*"
],
"dependencies": {
"axios": "^0.28.0",
"axios": "^0.27.0",
"axios-retry": "~3.2.5",
"https-proxy-agent": "^5.0.1"
},
Expand All @@ -42,11 +42,11 @@
"eslint-config-prettier": "^8.5.0",
"faker": "5.5.3",
"http-proxy": "^1.18.1",
"jest": "^29.3.1",
"jest": "^29.7.0",
"nock": "^13.2.4",
"prettier": "^2.6.2",
"tmp": "^0.2.1",
"ts-jest": "^29.0.3",
"ts-jest": "^29.2.5",
"typescript": "^4.7.2"
},
"keywords": [
Expand Down
36 changes: 2 additions & 34 deletions src/HttpClient.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import axios, {
AxiosError,
AxiosInstance,
AxiosProxyConfig,
AxiosRequestConfig,
AxiosResponse,
AxiosResponseHeaders
} from 'axios';
import axios, { AxiosError, AxiosInstance, AxiosProxyConfig, AxiosRequestConfig } from 'axios';
import { IClientResponse, ILogger, IProxyConfig, RetryOnStatusCode } from '../model';
import axiosRetry, { IAxiosRetryConfig } from 'axios-retry';
import { HttpsProxyAgent } from 'https-proxy-agent';
Expand Down Expand Up @@ -63,17 +56,9 @@ export class HttpClient {
}

public async doRequest(requestParams: IRequestParams): Promise<IClientResponse> {
const response : AxiosResponse = await this._axiosInstance(requestParams);

return {
data: response.data,
headers: this.mapHeaders(response.headers), // Use your mapHeaders function
status: response.status,
};
return await this._axiosInstance(requestParams);
}



public async doAuthRequest(requestParams: IRequestParams): Promise<IClientResponse> {
if (this._accessToken !== '') {
this.addAuthHeader(requestParams);
Expand Down Expand Up @@ -109,23 +94,6 @@ export class HttpClient {
}
}

private mapHeaders(headers?: AxiosResponseHeaders): { [key: string]: string } {
const mappedHeaders: { [key: string]: string } = {};

if (!headers) {
return mappedHeaders;
}

Object.keys(headers).forEach((key) => {
const headerValue : string | undefined = headers[key];
if (headerValue !== undefined) {
mappedHeaders[key] = headerValue.toString();
}
});

return mappedHeaders;
}

/**
* Use to create httpsAgent to handle Http proxy sending to a https server.
* (Artifactory is https server, proxy protocol can be both)
Expand Down

0 comments on commit db1afe8

Please sign in to comment.