1.0.3 • Published 11 years ago

request-buffer v1.0.3

Weekly downloads
4
License
-
Repository
github
Last release
11 years ago

Node RequestBuffer

An HTTP Request Buffer for Node.js

RequestBuffer enables simple late binding to the 'data' event for HTTP requests.

The Problem

Binding to the standard data and end events in Node.js' http.ServerRequest work in many situations. But as your application expands you'll often find that you need to call some asynchronous functions before you begin to work with the request body.

// ...
authenticateUser(function(authed) {
  if(authed) {
    request.on('data', function(chunk) {
      // It may be too late to bind at this point
    });
  }
});

The Solution

The simple solution is to always make sure you bind to the request events before any asynchronous functions are called. But passing the event data around and handling it properly can be difficult, especially when using a framework where the request data may need to be passed around by several methods.

This is where RequestBuffer comes in handy. RequestBuffer enables you to bind to the data event whenever you need without missing any data.

TODO: Sample Code

TODO: Installation

1.0.3

11 years ago

1.0.2

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago

0.0.0

11 years ago