(
url: URL | string,
options: http.RequestOptions = {}
)
| 1194 | * @internal |
| 1195 | */ |
| 1196 | export function get( |
| 1197 | url: URL | string, |
| 1198 | options: http.RequestOptions = {} |
| 1199 | ): Promise<{ body: string; status: number | undefined }> { |
| 1200 | return new Promise((resolve, reject) => { |
| 1201 | /* eslint-disable prefer-const */ |
| 1202 | let timeoutId: NodeJS.Timeout; |
| 1203 | const request = http |
| 1204 | .get(url, options, response => { |
| 1205 | response.setEncoding('utf8'); |
| 1206 | let body = ''; |
| 1207 | response.on('data', chunk => (body += chunk)); |
| 1208 | response.on('end', () => { |
| 1209 | clearTimeout(timeoutId); |
| 1210 | resolve({ status: response.statusCode, body }); |
| 1211 | }); |
| 1212 | }) |
| 1213 | .on('error', error => { |
| 1214 | clearTimeout(timeoutId); |
| 1215 | reject(error); |
| 1216 | }) |
| 1217 | .end(); |
| 1218 | timeoutId = setTimeout(() => { |
| 1219 | request.destroy(new MongoNetworkTimeoutError(`request timed out after 10 seconds`)); |
| 1220 | }, 10000); |
| 1221 | }); |
| 1222 | } |
| 1223 | |
| 1224 | /** @internal */ |
| 1225 | export const DOCUMENT_DB_CHECK = /(\.docdb\.amazonaws\.com$)|(\.docdb-elastic\.amazonaws\.com$)/; |
no test coverage detected