From 44f7cae85692302967e78a5a7a7541da5fb901af Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Sun, 4 Apr 2021 13:59:38 -0700 Subject: [PATCH] http: PRI upgrade should return PAUSED_H2_UPGRADE `PAUSED_UPGRADE` is a recoverable error and should not be returned when parsing HTTP/2 `PRI /...` preambule, which is the last message that can be parsed on the stream. --- src/llhttp/constants.ts | 1 + src/llhttp/http.ts | 6 ++++-- test/request/method.md | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/llhttp/constants.ts b/src/llhttp/constants.ts index 3da61705..a5cfed91 100644 --- a/src/llhttp/constants.ts +++ b/src/llhttp/constants.ts @@ -30,6 +30,7 @@ export enum ERROR { PAUSED, PAUSED_UPGRADE, + PAUSED_H2_UPGRADE, USER, } diff --git a/src/llhttp/http.ts b/src/llhttp/http.ts index 4511096e..a78f6dd1 100644 --- a/src/llhttp/http.ts +++ b/src/llhttp/http.ts @@ -375,8 +375,10 @@ export class HTTP { .otherwise(p.error(ERROR.INVALID_VERSION, 'Expected CRLF after version')); n('req_pri_upgrade') - .match('\r\n\r\nSM\r\n\r\n', p.error(ERROR.PAUSED_UPGRADE, 'Pause on PRI/Upgrade')) - .otherwise(p.error(ERROR.INVALID_VERSION, 'Expected HTTP/2 Connection Preface')); + .match('\r\n\r\nSM\r\n\r\n', + p.error(ERROR.PAUSED_H2_UPGRADE, 'Pause on PRI/Upgrade')) + .otherwise( + p.error(ERROR.INVALID_VERSION, 'Expected HTTP/2 Connection Preface')); } private buildHeaders(): void { diff --git a/test/request/method.md b/test/request/method.md index 49187034..60dcd8cb 100644 --- a/test/request/method.md +++ b/test/request/method.md @@ -386,5 +386,5 @@ SM off=0 message begin off=4 len=1 span[url]="*" off=6 url complete -off=24 error code=22 reason="Pause on PRI/Upgrade" +off=24 error code=23 reason="Pause on PRI/Upgrade" ```