node logoHey everyone! This is the fourth post in my new node.js modules you should know about article series.

The first post was about dnode - the freestyle rpc library for node, the second was about optimist - the lightweight options parser for node, the third was about lazy - lazy lists for node.

This time I'll introduce you to a very awesome module called request by Mikeal Rogers. Request is the swiss army knife of HTTP streaming.

Check this out:

var fs = require('fs')
var request = require('request');


Pow! You just streamed the response of HTTP request to into doodle.png local file!

Here is more awesome stuff:

var fs = require('fs')
var request = require('request');


Pow! It streamed your local file file.json to as HTTP PUT request!

var request = require('request');


Pow! This just streamed a HTTP GET from to HTTP PUT to

At Browserling we use this module for streaming data to and from couchdb. Here is an example that saves a JSON document at mikeal's test couchdb:

var request = require('request')
var rand = Math.floor(Math.random()*100000000).toString()

  method: 'PUT',
  uri: '' + rand,
  multipart: [
      'content-type': 'application/json',
      'body': JSON.stringify({
        foo: 'bar',
        _attachments: {
          'message.txt': {
            follows: true,
            length: 18,
            'content_type': 'text/plain'
    { body: 'I am an attachment' }
}, function (error, response, body) {
  if(response.statusCode == 201){
    console.log('document saved as:'+ rand);
  } else {
    console.log('error: '+ response.statusCode);

Install it via npm, as always:

npm install request

See ya!