Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ jobs:
- name: Install clang for Windows
if: runner.os == 'Windows'
run: |
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
iwr -useb get.scoop.sh -outfile 'install.ps1'
.\install.ps1 -RunAsAdmin
scoop install llvm --global

# Scoop modifies the PATH so we make the modified PATH global.
echo "::set-env name=PATH::$env:PATH"
echo $env:PATH >> $env:GITHUB_PATH

- name: Fetch code
uses: actions/checkout@v2
Expand All @@ -45,7 +46,8 @@ jobs:

- name: Build libllhttp.a
shell: bash
run: make build/libllhttp.a
run: |
make build/libllhttp.a

test:
name: Run tests
Expand All @@ -60,11 +62,12 @@ jobs:
- name: Install clang for Windows
if: runner.os == 'Windows'
run: |
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
iwr -useb get.scoop.sh -outfile 'install.ps1'
.\install.ps1 -RunAsAdmin
scoop install llvm --global

# Scoop modifies the PATH so we make the modified PATH global.
echo "::set-env name=PATH::$env:PATH"
echo $env:PATH >> $env:GITHUB_PATH

- name: Fetch code
uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Port of [http_parser][0] to [llparse][1].

**IMPORTANT: The 2.x series is discontinued and not maintained anymore. Update to the latest version of llhttp as soon as possible. The only exception is the 2.1.x series which will be supported until Node.js 14 goes End-Of-Life).**

## Why?

Let's face it, [http_parser][0] is practically unmaintainable. Even
Expand Down
87 changes: 62 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@
"homepage": "https://github.com/nodejs/llhttp#readme",
"devDependencies": {
"@types/mocha": "^5.2.7",
"@types/node": "^10.17.52",
"@types/node": "^10.17.60",
"llparse-dot": "^1.0.1",
"llparse-test-fixture": "^5.0.1",
"llparse-test-fixture": "^5.0.2",
"mdgator": "^1.1.2",
"mocha": "^7.2.0",
"ts-node": "^7.0.1",
"tslint": "^5.20.1",
"typescript": "^3.9.9"
"typescript": "^3.9.10"
},
"dependencies": {
"@types/semver": "^5.5.0",
"llparse": "^7.1.0",
"llparse": "^7.1.1",
"semver": "^5.7.1"
}
}
80 changes: 41 additions & 39 deletions src/llhttp/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,40 @@ export type HTTPMode = 'loose' | 'strict';

export enum ERROR {
OK = 0,
INTERNAL,
STRICT,
LF_EXPECTED,
UNEXPECTED_CONTENT_LENGTH,
CLOSED_CONNECTION,
INVALID_METHOD,
INVALID_URL,
INVALID_CONSTANT,
INVALID_VERSION,
INVALID_HEADER_TOKEN,
INVALID_CONTENT_LENGTH,
INVALID_CHUNK_SIZE,
INVALID_STATUS,
INVALID_EOF_STATE,
INVALID_TRANSFER_ENCODING,

CB_MESSAGE_BEGIN,
CB_HEADERS_COMPLETE,
CB_MESSAGE_COMPLETE,
CB_CHUNK_HEADER,
CB_CHUNK_COMPLETE,

PAUSED,
PAUSED_UPGRADE,

USER,
INTERNAL = 1,
STRICT = 2,
CR_EXPECTED = 25,
LF_EXPECTED = 3,
UNEXPECTED_CONTENT_LENGTH = 4,
CLOSED_CONNECTION = 5,
INVALID_METHOD = 6,
INVALID_URL = 7,
INVALID_CONSTANT = 8,
INVALID_VERSION = 9,
INVALID_HEADER_TOKEN = 10,
INVALID_CONTENT_LENGTH = 11,
INVALID_CHUNK_SIZE = 12,
INVALID_STATUS = 13,
INVALID_EOF_STATE = 14,
INVALID_TRANSFER_ENCODING = 15,

CB_MESSAGE_BEGIN = 16,
CB_HEADERS_COMPLETE = 17,
CB_MESSAGE_COMPLETE = 18,
CB_CHUNK_HEADER = 19,
CB_CHUNK_COMPLETE = 20,

PAUSED = 21,
PAUSED_UPGRADE = 22,
// PAUSED_H2_UPGRADE = 23 in v6.x

USER = 24,
}

export enum TYPE {
BOTH = 0, // default
REQUEST,
RESPONSE,
REQUEST = 1,
RESPONSE = 2,
}

export enum FLAGS {
Expand Down Expand Up @@ -187,8 +189,8 @@ Object.keys(METHOD_MAP).forEach((key) => {

export enum FINISH {
SAFE = 0,
SAFE_WITH_CB,
UNSAFE,
SAFE_WITH_CB = 1,
UNSAFE = 2,
}

// Internal
Expand Down Expand Up @@ -284,15 +286,15 @@ export const MINOR = MAJOR;

export enum HEADER_STATE {
GENERAL = 0,
CONNECTION,
CONTENT_LENGTH,
TRANSFER_ENCODING,
UPGRADE,

CONNECTION_KEEP_ALIVE,
CONNECTION_CLOSE,
CONNECTION_UPGRADE,
TRANSFER_ENCODING_CHUNKED,
CONNECTION = 1,
CONTENT_LENGTH = 2,
TRANSFER_ENCODING = 3,
UPGRADE = 4,

CONNECTION_KEEP_ALIVE = 5,
CONNECTION_CLOSE = 6,
CONNECTION_UPGRADE = 7,
TRANSFER_ENCODING_CHUNKED = 8,
}

export const SPECIAL_HEADERS = {
Expand Down
Loading