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

headary

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

headary

Summarize basic HTTP status codes and headers

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

headary - summarize HTTP headers

headary is a trivial Node package that provides a normalized summary of basic HTTP status codes and headers. You might use headary to write control flow for redirects and 304s in a uniform way. This can make sense if you handle responses at multiple locations in your code.

Build Status

example

var headary = require('headary')

// Get HTTP response `res` from somewhere.

var h = headary(res)
if (h.ok) {
  // Move on.
} else {
  if (h.message) {
    // Quaint or unhandled HTTP status.
    var er = new Error(h.message)
    this.emit('error', er)
  } else if (h.url) {
    // Issue request with new URL.
    if (h.permanent) {
      // Update some cache or whatever.
    }
  } else if (h.permanent) {
    // `410: Gone`, update cache.
  } else {
    // `304: Not Modified`, done.
  }
}

types

summary()

  • message String() | undefined An error message
  • ok Boolean() | false No further actions required
  • permanent Boolean() | false Resource been moved permanently
  • url String() | undefined The new location of the resource

exports

headary exports a single function that returns a summary() object.

headary(res)

Take a HTTP response, and return a summary() object.

The considered HTTP status codes:

  • 200 OK
  • 300 Multiple Choices
  • 301 Moved Permanently
  • 302 Found
  • 303 See Other
  • 304 Not Modified
  • 305 Use Proxy
  • 307 Temporary Redirect
  • 410 Gone

install

With npm do:

$ npm install headary

license

MIT License

Keywords

FAQs

Package last updated on 11 Jun 2015

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