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

spdy-v3

v1.2.1

Published

Implementation of the SPDY protocol on node.js.

Downloads

7

Readme

SPDY Server for node.js Build Status

With this module you can create SPDY servers in node.js with natural http module interface and fallback to regular https (for browsers that doesn't support SPDY yet).

Node+OpenSSL building

At the moment node-spdy requires zlib dictionary support, which will come to node.js only in 0.7.x version. To build 0.7.x version follow instructions below:

git clone git://github.com/joyent/node.git
cd node
./configure --prefix=$HOME/.node/dev # <- or any other dir

make install -j4 # in -jN, N is number of CPU cores on your machine

# Add node's bin to PATH env variable
echo 'export PATH=$HOME/.node/dev/bin:$PATH' >> ~/.bashrc

#
# You have working node 0.7.x + NPN now !!!
#

Usage

var spdy = require('spdy'),
    fs = require('fs');

var options = {
  key: fs.readFileSync(__dirname + '/keys/spdy-key.pem'),
  cert: fs.readFileSync(__dirname + '/keys/spdy-cert.pem'),
  ca: fs.readFileSync(__dirname + '/keys/spdy-csr.pem')
};

var server = spdy.createServer(options, function(req, res) {
  res.writeHead(200);
  res.end('hello world!');
});

server.listen(443);

API

API is compatible with http and https module, but you can use another function as base class for SPDYServer. For example, require('express').HTTPSServer given that as base class you'll get a server compatible with express API.

spdy.createServer(
  [base class constructor, i.e. https.Server or express.HTTPSServer],
  { /* keys and options */ }, // <- the only one required argument
  [request listener]
).listen([port], [host], [callback]);

Request listener will receive two arguments: request and response. They're both instances of http's IncomingMessage and OutgoingMessage. But two custom properties are added to both of them: streamID and isSpdy. The first one indicates on which spdy stream are sitting request and response. Latter one is always true and can be checked to ensure that incoming request wasn't received by HTTPS callback.

Push streams

It is possible to initiate 'push' streams to send content to clients before the client requests it.

spdy.createServer(options, function(req, res) {
  var headers = { 'content-type': 'application/javascript' };
  res.push('/main.js', headers, function(err, stream) {
    if (err) return;

    stream.end('alert("hello from push stream!");');
  });

  res.end('<script src="/main.js"></script>');
}).listen(443);

Push is accomplished via the push() method invoked on the current response object (this works for express.js response objects as well). The format of the push() method is:

.push('full or relative url', { ... headers ... }, callback)

You can use either full ( http://host/path ) or relative ( /path ) urls with .push(). headers are the same as for regular response object. callback will receive two arguments: err (if any error is happened) and stream (stream object have API compatible with a net.Socket ).

Options

All options supported by tls are working with node-spdy. In addition, maxStreams options is available. it allows you controlling [maximum concurrent streams][http://www.chromium.org/spdy/spdy-protocol/spdy-protocol-draft2#TOC-SETTINGS] protocol option (if client will start more streams than that limit, RST_STREAM will be sent for each additional stream).

Contributors

LICENSE

This software is licensed under the MIT License.

Copyright Fedor Indutny, 2012.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.