Skip to content

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

License

Notifications You must be signed in to change notification settings

overlookmotel/got-headers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

got-headers.js

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

Current status

NPM version Build Status Dependency Status Dev dependency Status Greenkeeper badge 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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published