Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stefanjudis/is-http2
Module to check for http/2 support
https://github.com/stefanjudis/is-http2
Last synced: 18 days ago
JSON representation
Module to check for http/2 support
- Host: GitHub
- URL: https://github.com/stefanjudis/is-http2
- Owner: stefanjudis
- License: mit
- Created: 2015-11-27T15:55:52.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-12-28T13:48:03.000Z (almost 7 years ago)
- Last Synced: 2024-10-15T07:12:13.996Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 39.1 KB
- Stars: 14
- Watchers: 3
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](http://img.shields.io/travis/stefanjudis/is-http2.svg?style=flat)](https://travis-ci.org/stefanjudis/is-http2) [![npm version](http://img.shields.io/npm/v/is-http2.svg?style=flat)](https://www.npmjs.org/package/is-http2) [![npm downloads](http://img.shields.io/npm/dm/is-http2.svg?style=flat)](https://www.npmjs.org/package/is-http2) [![Coverage Status](http://img.shields.io/coveralls/stefanjudis/is-http2.svg?style=flat)](https://coveralls.io/r/stefanjudis/is-http2?branch=master) [![Uses greenkeeper.io](https://img.shields.io/badge/Uses-greenkeeper.io-green.svg)](http://greenkeeper.io/)
# is-http2
Simple module to check if certain servers out there support HTTP/2.
## install
```
$ npm install --save is-http2
```## Pre-requisites
To make `is-http2` work, you need to have [openssl](http://openssl.org/) in a version greater than 1.0.0 installed and available in your `$path`.
## Basic usage
### isHttp2( url, options )
**Description** : Check if server behind given url supports HTTP/2
**url** : Url to check HTTP/2 support for
#### Options
* **includeSpdy** : optional: should SPDY be considered HTTP/2
* **openssl** : optional: specify custom openssl command (i.e. '/usr/local/Cellar/openssl/1.0.2k/bin/openssl')`isHttp2` returns a Promise which will be resolved with an Object containing `isHttp2` and `supportedProtocols`.
```javascript
const isHttp2 = require( 'is-http2' );isHttp2( 'twitter.com', { includeSpdy : true } )
.then( function( result ) {
if ( result.isHttp2 ) {
console.log( `${ chalk.green( '✓' ) } HTTP/2 supported by ${ host }` );
} else {
console.log( `${ chalk.red( '×' ) } HTTP/2 not supported by ${ host }` );
}if ( result.supportedProtocols ) {
console.log(
`Supported protocols: ${ result.supportedProtocols.join( ' ' ) }`
);
}
} )
.catch( function( error ) {
console.error( chalk.red( error ) );process.exit( 1 );
} );
```--------------------------------------------------------
#### I want to thank all these [people](./THANKS.md) for their great work!!!