New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ceicc/range

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ceicc/range

http range request handler

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

range

http range request handler

Installation

npm i @ceicc/range

Usage

start by requiring http and range

const
http = require("http"),
range = require("@ceicc/range");

Then make a simple server that responds with a file based on the requested path

http.createServer((req, res) => {

 range(__dirname + req.url, req.headers.range, res, err => {
   if (err?.code === 404) return res.writeHead(404).end("Page Not Found");
   if (err?.code === 416) return res.writeHead(416).end("Range Not Satisfiable");
   if (err) {
     console.error(err);
     res.writeHead(500).end("Internal Server Error");
   }
 });

}).listen(2000);

Parameters

  1. file path, starting from the current directory.

  2. the requested range. null and undefined treatet as there is no range.

  3. the response object.

  4. an error checking function.

Errors

possible errors are:

  1. File Not Found with error code: 404

  2. Range Not Satisfiable with error code: 416

Keywords

FAQs

Package last updated on 12 Sep 2021

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