mirror of
https://github.com/Kong/insomnia
synced 2024-11-12 17:26:32 +00:00
5f4c19da35
Co-authored-by: Opender Singh <opender.singh@konghq.com>
36 lines
889 B
TypeScript
36 lines
889 B
TypeScript
import { axiosRequest } from '../../network/axios-request';
|
|
|
|
/** This is a client for isomorphic-git {@link https://isomorphic-git.org/docs/en/http} */
|
|
export const httpClient = {
|
|
request: async config => {
|
|
let response;
|
|
let body: Buffer | null = null;
|
|
|
|
if (Array.isArray(config.body)) {
|
|
body = Buffer.concat(config.body);
|
|
}
|
|
|
|
try {
|
|
response = await axiosRequest({
|
|
url: config.url,
|
|
method: config.method,
|
|
headers: config.headers,
|
|
data: body,
|
|
responseType: 'arraybuffer',
|
|
maxRedirects: 10,
|
|
});
|
|
} catch (err) {
|
|
response = err.response;
|
|
}
|
|
|
|
return {
|
|
url: response.request.res.responseUrl,
|
|
method: response.request.method,
|
|
headers: response.headers,
|
|
body: [response.data],
|
|
statusCode: response.status,
|
|
statusMessage: response.statusText,
|
|
};
|
|
},
|
|
};
|