# node-http-intercept

> Intercepts node http.request. Allows conditional request modification.

Latest version **1.0.7** (published 2017-01-27) · (MIT OR Apache-2.0) license · 0 weekly downloads

## Install

```sh
npm install node-http-intercept
pnpm add node-http-intercept
yarn add node-http-intercept
bun add node-http-intercept
```

## Health

**Score 5/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2017-01-27 |
| First published | 2017-01-26 |
| Weekly downloads | 0 |
| License | (MIT OR Apache-2.0) |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jeff Wilde |
| Maintainers | gofreddo |
| Keywords | node, http, intercept |

## Links

- npm: https://www.npmjs.com/package/node-http-intercept
- Repository: https://github.com/gofreddo/http-intercept
- Homepage: https://github.com/gofreddo/http-intercept#readme
- Issues: https://github.com/gofreddo/http-intercep/issues
- npm.io page: https://npm.io/package/node-http-intercept

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [request](https://npm.io/package/request.md) ^2.79.0
- [fast-memoize](https://npm.io/package/fast-memoize.md) git+https://github.com/gofreddo/fast-memoize.js.git

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2017-01-27
- 1.0.6 — 2017-01-27
- 1.0.5 — 2017-01-26
- 1.0.4 — 2017-01-26
- 1.0.1 — 2017-01-26
- 1.0.0 — 2017-01-26

## README

# http-intercept

> Intercepts node http.request. Allows conditional request modification.

## Install

Install with [npm](https://www.npmjs.com/)

```sh
$ npm i http-intercept --save-dev
```

## Usage

```js
  const httpIntercept = require('http-intercept');
  const options = {
    hostname: 'google.com',
    port: 80,
    path: '/upload',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  };

  const interceptOptions = {
    searchValue: 'google',
    replaceValue: 'bing',
    callback: (newOptions) => {
      // newOptions.hostname ==='bing.com
    },
  };

  httpIntercept(interceptOptions);

  http.request(options);
```


```js
  const httpIntercept = require('http-intercept');
  const options = {
    hostname: 'google.com',
    port: 80,
    path: '/upload',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  };

  const interceptOptions = {
    searchValue: 'google',
    replaceValue: 'bing',
    callback: (newOptions) => {
      // newOptions is unchanged because predicate fails.
    },
    predicate: () => false,
  };

  httpIntercept(interceptOptions);

  http.request(options);
```


```js
  const httpIntercept = require('http-intercept');
  const options = {
    hostname: 'google.com',
    port: 80,
    path: '/upload',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  };

  const interceptOptions = {
    searchAndReplaceValues: [{
      google: 'bing',
    },
    {
      '.com': '.org',
    },
    ],
    callback: (newOptions) => {
      // hostname is now 'bing.org'
    },
  };

  httpIntercept(interceptOptions);

  http.request(options);
```

## Running tests

Install dev dependencies:

```sh
$ npm i -d && npm test
```

## Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/gofreddo/http-intercep/issues)

## Author

**Jeff Wilde**

* [github/](https://github.com/)
* [twitter/](http://twitter.com/)

## License

Copyright © 2017 [Jeff Wilde](#Jeff Wilde)
Licensed under the (MIT OR Apache-2.0) license.

***

_This file was generated by [readme-generator](https://github.com/jonschlinkert/readme-generator) on January 26, 2017._

---
_Source: https://npm.io/package/node-http-intercept · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
