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

http-headers-validation

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-headers-validation

Utility for validating HTTP header names and values

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.8K
increased by17.98%
Maintainers
1
Weekly downloads
 
Created
Source

http-headers-validation

Introduction

This is a small utility for validating HTTP header names and values according to the standart. It is useful in modules which expect users to provide some headers through options.

Install

This module can be used as npm package. To install it type:

$ npm install http-headers-validation

in the command line.

Also if you want to use the module as a client side library just import the index.js file through a <script> tag into your html document. The API is exposed through a global variable called headerUtils.

API

validateHeaderName(headerName)

  • headerName - A non-empty string representing the header name which we want to validate.

The function returns false if the headerName is invalid according to the standart and true otherwise.

var headerUtils = require('http-headers-validation');

headerUtils.validateHeaderName('If-Unmodified-Since'); // true
headerUtils.validateHeaderName('X-Forwarded-Host'); // true
headerUtils.validateHeaderName('Front-End-[]'); // false

validateHeaderValue(headerValue)

  • headerValue - A non-empty string representing the header value which we want to validate.

The function returns false if the headerValue is invalid according to the standart and true otherwise.

var headerUtils = require('http-headers-validation');

headerUtils.validateHeaderValue('VQcFUFFRCBABUFhaAwQOVw=='); // true
headerUtils.validateHeaderValue('valueWithTabulation\t'); // true
headerUtils.validateHeaderValue('\n\b'); // false

validateHeader(headerName, headerValue)

  • headerName - A non-empty string representing the header name which we want to validate.
  • headerValue - A non-empty string representing the header value which we want to validate.

The function returns false if headerName or headerValue is invalid and true otherwise.

var headerUtils = require('http-headers-validation');

headerUtils.validateHeader('Cache-Control', 'public, max-age=2000'); // true
headerUtils.validateHeader('Front-End-[]', 'backspace\bValue'); // false

Testing and contributing

Every suggestions for improvements and bugfixes are welcomed in the Issues section.

For testing the module you need npm installed:

$ npm install
$ npm test

License

MIT

Keywords

FAQs

Package last updated on 09 Aug 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