New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@types/http-headers

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/http-headers

TypeScript definitions for http-headers

  • 3.0.4
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
259
decreased by-38.48%
Maintainers
1
Weekly downloads
 
Created
Source

Installation

npm install --save @types/http-headers

Summary

This package contains type definitions for http-headers (https://github.com/watson/http-headers).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/http-headers.

index.d.ts

/// <reference types="node" />

import { ServerResponse } from "http";

export = httpHeaders;

/**
 * Parse the start-line and headers from an HTTP request or response.
 *
 * - Auto-detects and ignores body if present
 * - Fully [RFC 2068](http://www.rfc-base.org/txt/rfc-2068.txt) compliant
 * - Support multi-line headers (lines will be joined with a space)
 * - Support repeating headers
 *
 * @param data The data to parse.
 * @param [onlyHeaders=false] If `true`, only the headers object will be returned.
 *
 * @example
 * import * as net from 'net'
 * import httpHeaders = require('http-headers')
 *
 * // create TCP server
 * net.createServer((c) => {
 *   const buffers: Buffer[] = []
 *   c.on('data', buffers.push.bind(buffers))
 *   c.on('end', () => {
 *     const data = Buffer.concat(buffers)
 *
 *     // parse incoming data as an HTTP request and extra HTTP headers
 *     console.log(httpHeaders(data))
 *   })
 * }).listen(8080)
 *
 * @example
 * // If given an instance of `http.ServerResponse`, the response headers are
 * // automatically extracted, parsed and returned:
 *
 * import * as http from 'http'
 * import httpHeaders = require('http-headers')
 *
 * http.createServer((req, res) => {
 *   res.end('Hello World')
 *   console.log(httpHeaders(res))
 * }).listen(8080)
 */
declare function httpHeaders<T extends boolean>(
    data: string | Buffer | ServerResponse,
    onlyHeaders?: T,
): T extends true ? httpHeaders.Headers : (httpHeaders.RequestData | httpHeaders.ResponseData | httpHeaders.Headers);

declare namespace httpHeaders {
    interface RequestData {
        method: string;
        url: string;
        version: HttpVersion;
        headers: Headers;
    }

    interface ResponseData {
        version: HttpVersion;
        statusCode: number;
        statusMessage: string;
        headers: Headers;
    }

    interface HttpVersion {
        major: number;
        minor: number;
    }

    type Headers = {
        "set-cookie"?: string[] | undefined;
    } & { [key in string]?: string | undefined };
}

Additional Details

  • Last updated: Tue, 01 Oct 2024 22:07:40 GMT
  • Dependencies: @types/node

Credits

These definitions were written by BendingBender.

FAQs

Package last updated on 01 Oct 2024

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