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

https

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

https

https mediation


Version published
Weekly downloads
658K
decreased by-0.77%
Maintainers
1
Weekly downloads
 
Created

What is https?

The 'https' npm package is a core Node.js module that provides an easy way to make HTTP requests over TLS/SSL. It is used to create HTTPS servers and clients, enabling secure communication over the web.

What are https's main functionalities?

Creating an HTTPS Server

This feature allows you to create an HTTPS server using SSL/TLS certificates. The server listens on port 443 and responds with 'Hello, Secure World!' to any incoming requests.

const https = require('https');
const fs = require('fs');

const options = {
  key: fs.readFileSync('key.pem'),
  cert: fs.readFileSync('cert.pem')
};

https.createServer(options, (req, res) => {
  res.writeHead(200);
  res.end('Hello, Secure World!');
}).listen(443);

Making HTTPS Requests

This feature allows you to make HTTPS GET requests to a specified URL. The example fetches a JSON object from 'jsonplaceholder.typicode.com' and logs it to the console.

const https = require('https');

https.get('https://jsonplaceholder.typicode.com/todos/1', (resp) => {
  let data = '';

  // A chunk of data has been received.
  resp.on('data', (chunk) => {
    data += chunk;
  });

  // The whole response has been received.
  resp.on('end', () => {
    console.log(JSON.parse(data));
  });

}).on('error', (err) => {
  console.log('Error: ' + err.message);
});

Other packages similar to https

Keywords

FAQs

Package last updated on 20 Mar 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