Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bring back support for http #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/core/http_client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ResponseBodyValue, ResponseDescriptor, ResponseBodyType } from './respo
import fetch, { Response } from 'node-fetch';
import { deserializeProtobuf } from '../protobuf/deserializer';
import https from 'https';
import http from 'http';

const CONTENT_TYPE_JSON = 'application/json';
const CONTENT_TYPE_HTML = 'text/html';
Expand All @@ -16,9 +17,14 @@ export async function makeRequest(request: RequestDescriptor, protoCtx: ProtoCtx
const headers = convertHeaders(request.headers);

const sTime = Date.now();
const agent = new https.Agent({
rejectUnauthorized: false,
});
let agent: http.Agent;
if (url.toLowerCase().startsWith('https://')) {
agent = new https.Agent({
rejectUnauthorized: false,
});
} else {
agent = new http.Agent();
}
const resp = await fetch(url, { method, body, headers, agent });
const eTime = Date.now();

Expand Down