Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

got-headers

overlookmotel6MIT1.0.0

Hit URL and get HTTP headers only (using got module)

got, headers, head, http

readme

got-headers.js

Hit URL and get HTTP headers only (using got module)

Current status

NPM version Build Status Dependency Status Dev dependency Status Coverage Status

Usage

Function to hit a URL and stop as soon as headers are received i.e. do not fetch the body of the HTTP response.

Useful for example for checking the size of a large file without downloading it. Uses GET HTTP method (or whatever method requested) rather than HEAD as some servers may not support HEAD, or not use cookies with HEAD etc.

Returns a Bluebird Promise which resolves to the response object, or rejects with an error.

Uses got to make the HTTP request.

headers(url, [options])

const headers = require('got-headers');

headers('http://www.google.com').then(function(res) {
    // Print headers object
    console.log(res.headers);
}).catch(function(err) {
    // Print error
    console.log('Error!', err);

    // Print response object
    console.log(err.res);
});

options object is passed directly to got - use any of got's options.

Tests

Use npm test to run the tests. Use npm run cover to check coverage.

There are no tests at present but it seems to work fine!

Changelog

See changelog.md

Issues

If you discover a bug, please raise an issue on Github. https://github.com/overlookmotel/got-headers/issues

Contribution

Pull requests are very welcome. Please:

  • ensure all tests pass before submitting PR
  • add an entry to changelog
  • add tests for new features
  • document new functionality/API additions in README

changelog

Changelog

1.0.0

  • Initial release