Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spdy

Package Overview
Dependencies
Maintainers
2
Versions
206
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spdy

Implementation of the SPDY protocol on node.js.

  • 3.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is spdy?

The spdy npm package is designed to support the SPDY and HTTP/2 protocols in Node.js. It provides server and client functionality, allowing developers to create SPDY/HTTP2 servers and clients with ease. This package is particularly useful for improving web application performance by leveraging the advanced features of these protocols, such as multiplexing, server push, and header compression.

What are spdy's main functionalities?

Creating an SPDY/HTTP2 server

This code sample demonstrates how to create a simple SPDY/HTTP2 server using the spdy package along with Express. It sets up a server that listens on port 3000 and serves a simple message over SPDY/HTTP2.

const spdy = require('spdy');
const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.end('Hello over SPDY/HTTP2');
});

const options = {
  key: fs.readFileSync('<path-to-key>'),
  cert: fs.readFileSync('<path-to-cert>')
};

spdy.createServer(options, app).listen(3000, () => {
  console.log('Server is running on https://localhost:3000');
});

Creating an SPDY/HTTP2 client

This code sample shows how to create an SPDY/HTTP2 client that connects to a server. It demonstrates making a request to the server and handling the response, including reading response headers and data.

const spdy = require('spdy');
const http2 = require('http2');

const client = spdy.connect('https://localhost:3000', (err, socket) => {
  if (err) {
    throw new Error('Connection failed');
  }

  const req = http2.request({
    ':path': '/'
  });

  req.on('response', (headers) => {
    console.log('Response headers:', headers);
  });

  req.setEncoding('utf8');
  req.on('data', (chunk) => console.log(chunk));
  req.end();
});

Other packages similar to spdy

Keywords

FAQs

Package last updated on 13 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc