Socket
Socket
Sign inDemoInstall

on-http-end

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    on-http-end

Allows to capture HTTP response content and headers on request end.


Version published
Weekly downloads
2.4K
decreased by-17.91%
Maintainers
1
Install size
8.58 kB
Created
Weekly downloads
 

Readme

Source

on-http-end

Allows to capture HTTP response content and headers on request end.

Inspired by: https://github.com/kwhitley/apicache/blob/master/src/apicache.js

Install

npm i on-http-end

Usage

const onEnd = require('on-http-end')
const http = require('http')

const server = http.createServer((req, res) => {
  onEnd(res, (payload) => {
    console.log(payload)
  })

  res.setHeader('my-header', 'value')
  res.end('Hello Word!', 'utf-8')
})

server.listen(3000)

Output:

{
  status: 200,
  headers: [Object: null prototype] { 'my-header': 'value' },
  data: 'Hello Word!',
  encoding: 'utf-8'
}

Want to contribute?

This is your repo ;)

Note: We aim to be 100% code coverage, please consider it on your pull requests.

Keywords

FAQs

Last updated on 07 Apr 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc