Permalink
Browse files

bump and docs for x-forwarded headers

  • Loading branch information...
1 parent 7c7788d commit 2aab73a33b22426d44b84162dd25dfceb82f91a3 @substack committed Oct 11, 2011
Showing with 8 additions and 20 deletions.
  1. +2 −11 README.markdown
  2. +0 −5 example/forward.js
  3. +5 −3 lib/insert_headers.js
  4. +1 −1 package.json
View
@@ -55,8 +55,6 @@ Use a colon-separated string to specify a host and port in a route.
Use `""` for the host as a default route.
-An x-forwarded-for header will be sent automatically.
-
bouncy(cb)
==========
@@ -79,15 +77,8 @@ incoming data will be piped to and from it.
You can specify header fields to insert into the request with `opts.headers`.
-For instance you might want to add an `"x-forwarded-for"` header:
-
-```javascript
-var bouncy = require('bouncy');
-
-bouncy(function (req, bounce) {
- bounce(5000, { headers : 'x-forwarded-for' : req.socket.remoteAddress });
-}).listen(80);
-````
+By default, `"x-forwarded-for"`, `"x-forwarded-port"`, and `"x-forwarded-proto"`
+are all automatically inserted into the outgoing header.
bounce(port, ...), bounce(host, port, ...)
------------------------------------------
View
@@ -1,5 +0,0 @@
-var bouncy = require('bouncy');
-
-bouncy(function (req, bounce) {
- bounce(8002, { headers : 'x-forwarded-for' : req.socket.remoteAddress });
-}).listen(8001);
View
@@ -3,9 +3,11 @@ module.exports = function (bufs, headers) {
var insert = [];
for (var key in headers) {
- var b = new Buffer(key + ': ' + headers[key] + '\r\n');
- insert.push(b);
- bytesAdded += b.length;
+ if (typeof headers[key] === 'string' || headers[key]) {
+ var b = new Buffer(key + ': ' + headers[key] + '\r\n');
+ insert.push(b);
+ bytesAdded += b.length;
+ }
}
var w = new Buffer(4);
View
@@ -1,7 +1,7 @@
{
"name" : "bouncy",
"description" : "Bounce HTTP requests around for a load balancer or http host router completely transparently",
- "version" : "0.1.1",
+ "version" : "0.2.0",
"repository" : {
"type" : "git",
"url" : "git://github.com/substack/bouncy.git"

0 comments on commit 2aab73a

Please sign in to comment.