npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

httppp

v0.2.1

Published

Deal with only the bits of HTTP you care about. Let the streams flow.

Readme

HTTPPP

HyperText Transfer Protocol Partial Parser

Overview

HTTPPP lets you parse only the bits of HTTP that you really need. It is designed specifically to aid in the creation of proxies that need to be fast and support arbitrary HTTP-like protocols. It doesn't mess with the actual data being pushed through the connection, so it trivially supports websockets and other extensions that rely on upgrade functionality or similar.

Installation

Available via npm:

$ npm install httppp

Or via git:

$ git clone git://github.com/deoxxa/httppp.git node_modules/httppp

API

Parser constructor

Constructs a new httppp Parser object, optionally supplying some configuration information as an object.

new httppp.Parser(options);
// basic instantiation
var parser = new httppp.Parser();

// instantiation with options
var parser = new httppp.Parser({maximumHeaderBytes: 4096});

Arguments

  • options - an object specifying configuration parameters. The only available parameter right now is maximumHeaderBytes, which controls how many bytes the parser will try to read before it gives up and emits an error saying that the headers were too long.

#headers

The "headers" event is emitted when httppp has decided that it's parsed all the headers that are going to arrive. Note that this is only emitted once per connection, with the implication of that being that you won't know about pipelined requests.

The payload for the event is an array containing, in order, the request method, the path being requested, and an object containing headers. The object's keys are the header names, and the values are arrays containing the values collected for that header. The values are arrays because multiple headers with the same name may be sent (for example cookies).

parser.on("headers", onHeaders);
parser.on("headers", function onHeaders(info) {
  // "GET" or similar
  console.log(info[0]);

  // "/" or something
  console.log(info[1]);

  // {host: ["127.0.0.1"], cookie: ["a=b", "c=d"]}
  console.log(info[2]);
});

Example

You might want to look at example.js as well.

var net = require("net"),
    http = require("http"),
    httppp = require("httppp");

var server1_port = null,
    server2_port = null;

var proxy = net.createServer(function(socket) {
  var parser = new httppp.Parser();

  socket.pipe(parser);

  parser.on("error", function() {
    socket.end();
  });

  parser.on("headers", function(info) {
    console.log(new Date(), "proxy headers", info[0], info[1]);

    var host = (info[2].host && info[2].host.length) ? info[2].host[0] : null;

    // remove port from host header
    if (host) {
      host = host.split(":").shift();
    }

    switch (host) {
      case "localhost": parser.pipe(net.connect({port: server1_port})).pipe(socket); break;
      case "127.0.0.1": parser.pipe(net.connect({port: server2_port})).pipe(socket); break;
      default: socket.end(); break;
    }
  });
});

proxy.listen(3000, function() {
  console.log("listening on port", this.address().port);
});

var server1 = http.createServer(function(req, res) {
  console.log(new Date(), "http[1] request", req.url);

  res.end("hello there from server 1!");
});

server1.listen(function() {
  server1_port = this.address().port;
});

var server2 = http.createServer(function(req, res) {
  console.log(new Date(), "http[2] request", req.url);

  res.end("hello there from server 2!");
});

server2.listen(function() {
  server2_port = this.address().port;
});

License

3-clause BSD. A copy is included with the source.

Contact