Giter Site home page Giter Site logo

nebkat / http-parser-ts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from creationix/http-parser-js

1.0 1.0 0.0 463 KB

A pure TypeScript HTTP parser for node, based on http-parser-js.

Home Page: https://www.npmjs.com/package/http-parser-ts

License: Other

TypeScript 100.00%

http-parser-ts's Introduction

http-parser-ts

This library is based on the original http-parser-js library by Tim Caswell (https://github.com/creationix/http-parser-js) but is rewritten in TypeScript to be easier to understand and extend.

HTTP Parser

This library parses HTTP protocol for requests and responses. It was created to replace http_parser.c since calling C++ function from JS is really slow in V8. However, it is now primarily useful in having a more flexible/tolerant HTTP parser when dealing with legacy services that do not meet the strict HTTP parsing rules Node's parser follows.

This is packaged as a standalone npm module. To use in node, run HTTPParser.bind() before importing http.

// Monkey patch before you require http for the first time
require('http-parser-ts').HTTPParser.bind();
// or ES6 module
import { HTTPParser } from 'http-parser-ts';
HTTPParser.bind();

let http = require('http');
// ...

Status

This should now be usable in any node application, it now supports (nearly) everything http_parser.c does while still being tolerant with corrupted headers, and other kinds of malformed data.

Node Versions

http-parser-ts should work via monkey-patching on Node v6-v11, and v13-v14.

Node v12.x renamed the internal http parser, and did not expose it for monkey-patching, so to be able to monkey-patch on Node v12, you must run node --http-parser=legacy file.js to opt in to the old, monkey-patchable http_parser binding.

License

MIT. See LICENSE.md

http-parser-ts's People

Contributors

creationix avatar danthegoodman avatar erikwilson avatar hackwaly avatar hdkeeper avatar jdforsythe avatar jimbly avatar jscissr avatar lrowe avatar magicode avatar mscdex avatar nebkat avatar nleush avatar paulrutter avatar phated avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.