http-parser-js
- Version 0.5.10
- Published
- 26.5 kB
- No dependencies
- MIT license
Install
npm i http-parser-jsyarn add http-parser-jspnpm add http-parser-jsOverview
A pure JS HTTP parser for node.
Index
Variables
Classes
HTTPParserJS
- [HTTPParser.kOnBody]
- [HTTPParser.kOnHeaders]
- [HTTPParser.kOnHeadersComplete]
- [HTTPParser.kOnMessageComplete]
- close
- consume
- execute()
- finish()
- free
- getAsyncId
- getCurrentBuffer
- initialize()
- maxHeaderSize
- onBody
- onHeaders
- onHeadersComplete
- onMessageComplete
- parseHeader()
- pause
- reinitialize
- resume
- shouldKeepAlive()
- unconsume
- userCall()
Interfaces
Type Aliases
Variables
variable HTTPParser
const HTTPParser: HTTPParserConstructor;variable methods
const methods: string[];Classes
class HTTPParserJS
class HTTPParserJS {}property [HTTPParser.kOnBody]
[HTTPParser.kOnBody]: OnBodyParser;property [HTTPParser.kOnHeaders]
[HTTPParser.kOnHeaders]: OnHeadersParser;property [HTTPParser.kOnHeadersComplete]
[HTTPParser.kOnHeadersComplete]: ( info: HeaderInfo<HeaderObject>) => number | void;property [HTTPParser.kOnMessageComplete]
[HTTPParser.kOnMessageComplete]: noop<void>;property close
close: noop<void>;property consume
consume: noop<void>;property free
free: noop<void>;property getAsyncId
getAsyncId: noop<0>;property getCurrentBuffer
getCurrentBuffer: noop<void>;property maxHeaderSize
maxHeaderSize: number;Max number of bytes that will be parsed as headers, 80kb by default 81920
property onBody
onBody: OnBodyParser;property onHeaders
onHeaders: OnHeadersParser;property onHeadersComplete
onHeadersComplete: (info: HeaderInfo<HeaderObject>) => number | void;property onMessageComplete
onMessageComplete: noop<void>;property pause
pause: noop<void>;property reinitialize
reinitialize: HTTPParserConstructor;property resume
resume: noop<void>;property unconsume
unconsume: noop<void>;method execute
execute: (chunk: Buffer, start?: number, length?: number) => number | Error;method finish
finish: () => void | Error;method initialize
initialize: (type: ParserType, async_resource?: unknown) => void;method parseHeader
parseHeader: (line: string, headers: string[]) => void;method shouldKeepAlive
shouldKeepAlive: () => boolean;method userCall
userCall: <T = unknown>() => (ret?: T) => T;For correct error handling - see HTTPParser#execute
Example 1
this.userCall()(userFunction('arg'));
Interfaces
interface HTTPParserConstructor
interface HTTPParserConstructor extends Function {}property encoding
encoding: 'ascii' | string;property kOnBody
readonly kOnBody: 3;property kOnHeaders
readonly kOnHeaders: 1;property kOnHeadersComplete
readonly kOnHeadersComplete: 2;property kOnMessageComplete
readonly kOnMessageComplete: 4;property maxHeaderSize
maxHeaderSize: 81920 | number;maxHeaderSize (in bytes) is configurable, but 80kb by default; 80 * 1024 = 80kb
property methods
readonly methods: RequestMethod[];property prototype
readonly prototype: HTTPParserJS;property REQUEST
readonly REQUEST: 'REQUEST';property RESPONSE
readonly RESPONSE: 'RESPONSE';method kOnExecute
kOnExecute: () => void;construct signature
new (type?: ParserType): HTTPParserJS;call signature
(type?: ParserType): void;Type Aliases
type HeaderInfo
type HeaderInfo<HEADER = HeaderObject> = { versionMajor: number; versionMinor: number; headers: HEADER; method: number; url: string; statusCode: number; statusMessage: string; upgrade: boolean; shouldKeepAlive: boolean;};type HeaderObject
type HeaderObject = Array<string>;type noop
type noop<T = void> = () => T;type OnBodyParser
type OnBodyParser = (chunk: Buffer, offset: number, length: number) => void;type OnHeadersCompleteParser
type OnHeadersCompleteParser< HEADER = HeaderObject, Mode_0_12 extends boolean = true> = Mode_0_12 extends true ? (info: HeaderInfo<HEADER>) => number | void : ( versionMajor: number, versionMinor: number, headers: HEADER, method: number, url: string, statusCode: number, statusMessage: string, upgrade: boolean, shouldKeepAlive: boolean ) => number | void;type OnHeadersParser
type OnHeadersParser = (headers: string[], url: string) => void;type ParserType
type ParserType = 'REQUEST' | 'RESPONSE';type RequestMethod
type RequestMethod = | 'DELETE' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'COPY' | 'LOCK' | 'MKCOL' | 'MOVE' | 'PROPFIND' | 'PROPPATCH' | 'SEARCH' | 'UNLOCK' | 'BIND' | 'REBIND' | 'UNBIND' | 'ACL' | 'REPORT' | 'MKACTIVITY' | 'CHECKOUT' | 'MERGE' | 'M-SEARCH' | 'NOTIFY' | 'SUBSCRIBE' | 'UNSUBSCRIBE' | 'PATCH' | 'PURGE' | 'MKCALENDAR' | 'LINK' | 'UNLINK' | string;type StateFinishAllowedKey
type StateFinishAllowedKey = 'REQUEST_LINE' | 'RESPONSE_LINE' | 'BODY_RAW';type StateHeaderKey
type StateHeaderKey = 'REQUEST_LINE' | 'RESPONSE_LINE' | 'HEADER';Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/http-parser-js.
- Markdown[](https://www.jsdocs.io/package/http-parser-js)
- HTML<a href="https://www.jsdocs.io/package/http-parser-js"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3537 ms. - Missing or incorrect documentation? Open an issue for this package.
