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

SPLT-689 custom headers #58

Merged
merged 13 commits into from
Dec 20, 2023
Merged
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@
"module": true,
"require": true
},
"parserOptions": {
"ecmaVersion": 9
},
"extends": "eslint:recommended"
}
5 changes: 4 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file. For change log formatting, see http://keepachangelog.com/

## 4.0.0 (Unreleased)
## 4.1.0
- Adds option to include given headers in requests

## 4.0.0
- Released under the `@mapbox/aws-log-replay` namespace.
- Replace `requestretry` with `got` for the HTTP client [#57](https://github.com/mapbox/aws-log-replay/pull/57)
- Test on Node 16 and 18
Expand Down
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function GeneratePath(type, keepReferer = false) {
* @param {object} options
* @param {string} options.baseurl - Required. An http or https url prepended to paths when making requests.
* @param {string} options.strictSSL - Optional. If true (default), requires SSL/TLS certificates to be valid
* @param {object} options.headers - Optional. Headers to applied to requests
*/
function RequestStream(options) {
options = options || {};
Expand Down Expand Up @@ -127,6 +128,10 @@ function RequestStream(options) {
gotOptions.headers = { referer };
}

if(options.headers) {
gotOptions.headers = { ...gotOptions.headers, ...options.headers };
}

got(url, gotOptions)
.then(({ statusCode, body, timings }) => {
this.push({
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "@mapbox/aws-log-replay",
"license": "BSD-2-Clause",
"author": "Mapbox",
"version": "4.0.0",
"version": "4.1.0",
"dependencies": {
"agentkeepalive": "^3.5.1",
"got": "^11.8.6",
Expand Down
Loading