An open API service indexing awesome lists of open source software.

https://github.com/tomnomnom/george

HTTP Debugging Proxy
https://github.com/tomnomnom/george

Last synced: about 2 months ago
JSON representation

HTTP Debugging Proxy

Awesome Lists containing this project

README

        

# george - HTTP debugging proxy

A really basic HTTP proxy written in node.js with hooks to let you re-write headers on request and response.

## A word of warning
If there were a greek letter before alpha then it would describe the state of george. If george was a real
person he would randomly refuse to do perfectly reasonable tasks that you ask of him.

## Methods
* `george.listen(port)` - start the proxy server listening on a port (default: 7070)
* `george.rewriteUrl(search, replace)` - rewrite requests from `search` to `replace`
* `george.on(event, callback)` - bind a callback to an event

### Events
* `request` - emitted before a request is made. A request object is the only argument.
* `response` - emitted after a response is received, but before it is sent to the client. A response object is the only argument.

## Examples

The most basic usage:

var george = require('george');
george.listen(7070);

A more complex example:

var george = require('george');

// Log the URL being requested
george.on('request', function(request){
console.log(request.url);
});

george.on('response', function(response){
// Globally replace "monospace" with "sans-serif" in the response body
response.body = response.body.replace(/monospace/g, 'sans-serif');

// Change the content-type to be text/plain
response.headers['content-type'] = 'text/plain';
});

// Start George listening on port 7070
george.listen(7070);

## Known issues
* There is currently no guarantee that callbacks run in time if they're async
* Gzip et al is not supported
* SSL isn't supported either
* Non-text data is not support in general