Constructor
new HttpClient(customOptions)
Creates a new HttpClient instance.
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
customOptions | Configuration object Properties
|
- Source
const client = new HttpClient({
timeout: 5000,
retry: { limit: 3, delay: 1000 },
proxy: 'http://proxy.corp.com:8080',
noProxy: 'localhost,127.0.0.1,.internal.com',
headers: { 'x-custom-header': 'my-custom-header' }
});Members
noProxy
List of hostnames that should bypass the corporate proxy
- Source
primaryOrigin
Initialized request options (headers, etc.)
- Source
sensitiveHeaders
List of sensitive headers
- Source
Methods
(async) fetchText(url)
Fetches a playlist and validates its HLS structure.
| Name | Type | Description |
|---|---|---|
url | string | The M3U8 playlist URL |
- Source
If the response body is not a valid HLS manifest
- Type
- InvalidPlayList
The raw string content of the playlist
getRequestHeaders(targetUrl)
Get Request headers
| Name | Type | Description |
|---|---|---|
targetUrl | string | target url to get the request for |
- Source
request headers
(async) getStream(url)
Fetches a resource (usually a .ts segment) as a stream.
| Name | Type | Description |
|---|---|---|
url | string | The segment URL |
- Source
If the response body is empty
- Type
- Error
A readable stream of the resource
(async) handleRetry(url, attempt)
Calculates exponential backoff and waits before retrying.
| Name | Type | Description |
|---|---|---|
url | string | url to handle retry for |
attempt | number | attempt to calculate backoff |
- Source
Fetch API Response
(async) requestWithRetry(url, attempt)
Core request wrapper with retry logic and timeout management. Handles cleanup of AbortController timers to prevent memory leaks.
| Name | Type | Default | Description |
|---|---|---|---|
url | string | url to fetch | |
attempt | number | 0 | [attempt=0] - retry attempt |
- Source
If request fails permanently or retries are exhausted.
- Type
- Error
Fetch API Response
setPrimaryOrigin(url)
Sets the primary origin based on the initial playlist URL.
| Name | Type | Description |
|---|---|---|
url | string | url to set primary origin from |
- Source
shouldBypassProxy(url)
Determines if a given URL should ignore the configured proxy. Logic matches hostnames or suffix patterns (e.g., '.internal.com').
| Name | Type | Description |
|---|---|---|
url | string | domain to bypass |
- Source
Boolean
