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 🙏

© 2024 – Pkg Stats / Ryan Hefner

fastcgi-stream

v1.0.0

Published

Fast FastCGI Stream wrapper for reading/writing FCGI records.

Downloads

480

Readme

fastcgi-stream

Build Status Dependency Information Code Climate Test Coverage npmjs.org

Read & write FastCGI records from a node.js stream like a boss.

Quickstart

npm install fastcgi-stream --save

The FastCGI stream library has two main pieces, the FastCGIStream itself and the records that can be sent and received on it.

The FastCGIStream wraps an existing Stream to send/receive FCGI records on. 99% of the time this is going to be a net.Socket.

var fastcgi = require('fastcgi-stream');

var fcgiStream = new fastcgi.FastCGIStream(mySocket);

// Send FastCGI records.
fcgiStream.writeRecord(requestId, new fastcgi.records.BeginRequest(
	fastcgi.records.BeginRequest.roles.RESPONDER,
	fastcgi.records.BeginRequest.flags.KEEP_CONN
));

// Receive FastCGI records.
fcgiStream.on('record', function(requestId, record) {
	if(requestId == fastcgi.constants.NULL_REQUEST_ID) {
		// Management record.
	}
	else {
		switch(record.TYPE) {
			case fastcgi.records.BeginRequest.TYPE: {
				// Request beginning. What role are we being asked to fulfill?
				if(record.role == fastcgi.records.BeginRequest.role.RESPONDER) {
					// Etc...
				}
				
				break;
			}
		}
	}
});

Records

All record objects live in the fastcgi.records namespace. Each record will now be listed. The listing will detail the constructor and parameters each record contains.

Constructor args are never mandatory, you can pass as many or as few arguments as you like.

BeginRequest

var record = new fastcgi.records.BeginRequest(role, flags);
  • .role - the role being requested. Possible roles as follows:
    • fastcgi.records.BeginRequest.roles.RESPONDER
    • fastcgi.records.BeginRequest.roles.AUTHORIZER
    • fastcgi.records.BeginRequest.roles.FILTER
  • .flags - additional flags for the request. There is only one in the specification:
    • fastcgi.records.BeginRequest.flags.KEEP_CONN

AbortRequest

var record = new fastcgi.records.AbortRequest();

EndRequest

var record = new fastcgi.records.EndRequest(appStatus, protocolStatus);
  • .appStatus - application return status code
  • .protocolStatus - protocol return status code, can be one of the following:
    • fastcgi.records.EndRequest.protocolStatus.REQUEST_COMPLETE
    • fastcgi.records.EndRequest.protocolStatus.CANT_MPX_CONN
    • fastcgi.records.EndRequest.protocolStatus.OVERLOADED
    • fastcgi.records.EndRequest.protocolStatus.UNKNOWN_ROLE

Params

var params = [
	['Name', 'Value'],
	['AnotherName', 'AnotherValue']
];

// Params is optional.
var record = new fastcgi.records.Params(params);

.params - an array of name/value array pairs

StdIn/StdOut/StdErr/Data

All of these records take the same constructor and have the same properties.

var body = 'String';
var record = new fastcgi.records.StdIn(body);

// .. or ..

var body = new Buffer('Contents.');
var record = new fastcgi.records.StdIn(body);

GetValues

var values = ['Name', 'AnotherName'];
var record = new fastcgi.records.GetValues(values);

.values - array of values being requested

GetValuesResult

var result = [
	['Name', 'Value'],
	['AnotherName', 'AnotherValue']
];

var record = new fastcgi.records.GetValuesResult(result);

.values - array of name/value pairs representing the result.

UnknownType

var record = new fastcgi.records.UnknownType(type);

.type - the type of record that was not recognized.

License

node-fastcgi-stream is free and unencumbered public domain software. For more information, see the accompanying UNLICENSE file.