Record & Replay HTTP streams by node.js
rnr creates a proxy server between user client and remote server.It records responses from remote server in file system and replays them when user client request again.
request __________ request ________
user → | has | → | remote |
client ← | records? | ← | server |
response |__________| response |________|
↑ ↓
file system
Install it:
npm install node-rnr -g
rnr --target [remote server host]
Proxy:
# dumb proxy
rnr --target http://localhost:8888
Record & Replay:
# record client requests
rnr --record --target http://localhost:8888
# replay request with records
rnr --replay --target http://localhost:8888
See a list of all available options:
rnr --help
You can use config file instead of command line options:
// rnr.config.js
module.exports = {
record: true,
replay: false,
port: 5000,
proxy: {
target: 'http://localhost:8888',
changeOrigin: true,
},
verbose: true,
}
Run this command to use the config file:
rnr -c # default config file rnr.config.js
rnr -c my.rnr.config.js # customize config file
MIT © BinRui.Guan