Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
harproxyserver
Advanced tools
A simple proxy server that records and plays back HTTP requests and responses in HAR format.
HAR Proxy Server is a simple proxy server that records and plays back HTTP requests and responses in HAR format. It can be used as a standalone executable or integrated into other projects as an npm package.
To install the server as a global command-line utility:
npm install --location=global harproxyserver
Run the server using the harServer command:
Start the server in play mode (default)
harproxyserver -p 3000 -f recorded.har
Start the server in record mode
harproxyserver -p 3000 -t http://example.com -f recorded.har -m record
Start the server with HTTPS
harproxyserver -p 3000 -f recorded.har --tls --key-file server.key --cert-file serv
Filter HAR file, to return only requests containing "forklift.konveyor.io" or "forklift-console-plugin" in the URL.
harproxyserver -m filter -f recorded.har --filter-endpoint-regexp "forklift.konveyor.io|forklift-console-plugin"
Before running the code from source, compile it using, npm run build
, the compiled sources will be added to the dist
directory.
# Compile development code
npm run build
# Run development code
node dist/harProxyServer.js [options ...]
Import the server and utility functions in your TypeScript project:
import { findHarEntry, recordedHarMiddleware } from 'harproxyserver';
Example 1: Using findHarEntry to find a specific GET request in a HAR log:
const harLog = ... // retrieve HAR log
const method = 'GET';
const pathname = '/api';
const entry = findHarEntry(harLog, method, pathname);
if (entry) {
console.log(`Found entry with ID ${entry.id}`);
} else {
console.log('Entry not found');
}
Example 2: Using findHarEntry to find a POST request with specific query parameters:
const harLog = ... // retrieve HAR log
const method = 'POST';
const baseUrl = 'https://example.com/api';
const queryParams = { q: 'search term', page: 1 };
const url = new URL(baseUrl);
for (const [key, value] of Object.entries(queryParams)) {
url.searchParams.set(key, value);
}
const pathnameWithParams = `${url.pathname}${url.search};
const entry = findHarEntry(harLog, method, pathnameWithParams);
if (entry) {
console.log(`Found entry with ID ${entry.id}`);
} else {
console.log('Entry not found');
}
The available options for this tool are:
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
FAQs
A simple proxy server that records and plays back HTTP requests and responses in HAR format.
We found that harproxyserver demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.