<commit_before><p align="center">
  <img src="doc/logo.png?raw=true"/>
</p>

node-http-proxy
=======

`node-http-proxy` is an HTTP programmable proxying library that supports 
websockets. It is suitable for implementing components such as
proxies and load balancers.

### Build Status

<p align="center">
 <a href="https://travis-ci.org/nodejitsu/node-http-proxy" target="_blank">
 	<img src="https://travis-ci.org/nodejitsu/node-http-proxy.png?branch=caronte"/></a>&nbsp;&nbsp;
 <a href="https://coveralls.io/r/nodejitsu/node-http-proxy" target="_blank">
 	<img src="https://coveralls.io/repos/nodejitsu/node-http-proxy/badge.png?branch=caronte"/></a>
</p>

### Core Concept

A new proxy is created by calling `createProxyServer` and passing
an `options` object as argument ([valid properties are available here](tree/master/lib/http-proxy.js#L26-L39)) 

```javascript
var httpProxy = require('http-proxy');

var proxy = httpProxy.createProxyServer(options);
```

An object will be returned with four values:

* web `req, res, [options]` (used for proxying regular HTTP(S) requests)
* ws `req, socket, head, [options]` (used for proxying WS(S) requests)
* ee (an EventEmitter2 that emits events, you can hook into them to customize behaviour)
* listen `port` (a function that wraps the object in a webserver, for your convenience)

Is it then possible to proxy requests by calling these functions

```javascript
require('http').createServer(function(req, res) {
  proxy.web(req, res, { target: 'http://mytarget.com:8080' });
});
```

When a request is proxied it follows two different pipelines ([available here](tree/master/lib/http-proxy/passes))
which apply transformations to both the `req` and `res` object. 
The first pipeline (ingoing) is responsible for the creation and manipulation of the stream that connects your client to the target.
The second pipeline (outgoing) is responsible for the creation and manipulation of the stream that, from your target, returns data 
to the client.

You can easily add a `pass` (stages) into both the pipelines (XXX: ADD API).

In addition, every stage emits a corresponding event so introspection during the process is always available.

#### Setup a basic stand-alone proxy server

```js<commit_msg>attempting to fix link to valid options properties<commit_after><p align="center">
  <img src="doc/logo.png?raw=true"/>
</p>

node-http-proxy
=======

`node-http-proxy` is an HTTP programmable proxying library that supports 
websockets. It is suitable for implementing components such as
proxies and load balancers.

### Build Status

<p align="center">
 <a href="https://travis-ci.org/nodejitsu/node-http-proxy" target="_blank">
 	<img src="https://travis-ci.org/nodejitsu/node-http-proxy.png?branch=caronte"/></a>&nbsp;&nbsp;
 <a href="https://coveralls.io/r/nodejitsu/node-http-proxy" target="_blank">
 	<img src="https://coveralls.io/repos/nodejitsu/node-http-proxy/badge.png?branch=caronte"/></a>
</p>

### Core Concept

A new proxy is created by calling `createProxyServer` and passing
an `options` object as argument ([valid properties are available here](lib/http-proxy.js#L26-L39)) 

```javascript
var httpProxy = require('http-proxy');

var proxy = httpProxy.createProxyServer(options);
```

An object will be returned with four values:

* web `req, res, [options]` (used for proxying regular HTTP(S) requests)
* ws `req, socket, head, [options]` (used for proxying WS(S) requests)
* ee (an EventEmitter2 that emits events, you can hook into them to customize behaviour)
* listen `port` (a function that wraps the object in a webserver, for your convenience)

Is it then possible to proxy requests by calling these functions

```javascript
require('http').createServer(function(req, res) {
  proxy.web(req, res, { target: 'http://mytarget.com:8080' });
});
```

When a request is proxied it follows two different pipelines ([available here](lib/http-proxy/passes))
which apply transformations to both the `req` and `res` object. 
The first pipeline (ingoing) is responsible for the creation and manipulation of the stream that connects your client to the target.
The second pipeline (outgoing) is responsible for the creation and manipulation of the stream that, from your target, returns data 
to the client.

You can easily add a `pass` (stages) into both the pipelines (XXX: ADD API).

In addition, every stage emits a corresponding event so introspection during the process is always available.

#### Setup a basic stand-alone proxy server

```js
{'fraction_non_alphanumeric': 0.12203239405369426, 'fraction_numerical': 0.0039937874417572666, 'mean_word_length': 5.0754716981132075, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2383432', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1308, 'n_words': 504}