mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[docs] readme
This commit is contained in:
parent
8c8c455541
commit
886a870707
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
||||
node_modules
|
||||
*.swp
|
||||
cov
|
||||
!ttest.js
|
||||
atest.js
|
||||
notes
|
||||
|
||||
46
README.md
Normal file
46
README.md
Normal file
@ -0,0 +1,46 @@
|
||||
Caronte
|
||||
=======
|
||||
|
||||
Caronte is an HTTP programmable proxying library that supports
|
||||
websockets. It is suitable for implementing components such as
|
||||
proxies and load balancers.
|
||||
|
||||
### Contributing and Issues
|
||||
|
||||
* Search on Google/Github
|
||||
* If you can't find anything, open an issue
|
||||
* If you feel comfortable about fixing the issue, fork the repo
|
||||
* Commit to your local branch (which must be different from `master`)
|
||||
* Submit your Pull Request (be sure to include tests and update documentation)
|
||||
|
||||
### Test
|
||||
|
||||
```
|
||||
$ npm test
|
||||
```
|
||||
|
||||
### License
|
||||
|
||||
```
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Nodejitsu Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
```
|
||||
67
ttest.js
67
ttest.js
@ -1,67 +0,0 @@
|
||||
'use strict'; /* jshint node:true */
|
||||
var caronte = require('./'),
|
||||
http = require('http'),
|
||||
ws = require('ws');
|
||||
|
||||
/*var proxyTo = new ws.Server({ port: 9090 });
|
||||
|
||||
proxyTo.on('connection', function(ws) {
|
||||
console.log('connection!');
|
||||
ws.on('message', function(msg) {
|
||||
ws.send('ohai: ' + msg);
|
||||
setTimeout(function() {
|
||||
ws.send('HAHAHHA');
|
||||
}, 10000);
|
||||
});
|
||||
ws.send('derpity?');
|
||||
});
|
||||
|
||||
var client = new ws('ws://127.0.0.1:8000');
|
||||
client.on('open', function() {
|
||||
client.send('baaaka');
|
||||
console.log('sent: baaaaka');
|
||||
setTimeout(function() {
|
||||
client.send('cacca');
|
||||
}, 5000);
|
||||
client.on('message', function(msg) {
|
||||
console.log('server said: ' + msg);
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
caronte.createProxyServer({
|
||||
ws : true,
|
||||
forward: 'http://127.0.0.1:9090'
|
||||
}).listen(8080);
|
||||
|
||||
|
||||
|
||||
var srv = http.createServer(function(req, res) {
|
||||
res.end('ciao proxy');
|
||||
console.log('suca');
|
||||
}).listen(9090);
|
||||
/*
|
||||
srv.on('upgrade', function(req, sock, head) {
|
||||
|
||||
var options = {
|
||||
port: 9090,
|
||||
hostname: '127.0.0.1',
|
||||
headers: req.headers
|
||||
}
|
||||
var r = http.request(options);
|
||||
|
||||
r.on('upgrade', function(res, proxySock, hd) {
|
||||
if (hd && hd.length) proxySock.unshift(hd);
|
||||
|
||||
sock.write('HTTP/1.1 101 Switching Protocols\r\n');
|
||||
sock.write(Object.keys(res.headers).map(function(i) {
|
||||
return i + ": " + res.headers[i];
|
||||
}).join('\r\n') + '\r\n\r\n');
|
||||
proxySock.pipe(sock).pipe(proxySock);
|
||||
});
|
||||
|
||||
r.end();
|
||||
});
|
||||
|
||||
*/
|
||||
Loading…
x
Reference in New Issue
Block a user