Skip to content

Commit 374434d

Browse files
committed
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. PR-URL: #95 Reviewed-By: Daniele Belardi <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent d4edb33 commit 374434d

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/llhttp/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export enum ERROR {
3030

3131
PAUSED,
3232
PAUSED_UPGRADE,
33+
PAUSED_H2_UPGRADE,
3334

3435
USER,
3536
}

src/llhttp/http.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,10 @@ export class HTTP {
375375
.otherwise(p.error(ERROR.INVALID_VERSION, 'Expected CRLF after version'));
376376

377377
n('req_pri_upgrade')
378-
.match('\r\n\r\nSM\r\n\r\n', p.error(ERROR.PAUSED_UPGRADE, 'Pause on PRI/Upgrade'))
379-
.otherwise(p.error(ERROR.INVALID_VERSION, 'Expected HTTP/2 Connection Preface'));
378+
.match('\r\n\r\nSM\r\n\r\n',
379+
p.error(ERROR.PAUSED_H2_UPGRADE, 'Pause on PRI/Upgrade'))
380+
.otherwise(
381+
p.error(ERROR.INVALID_VERSION, 'Expected HTTP/2 Connection Preface'));
380382
}
381383

382384
private buildHeaders(): void {

test/request/method.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,5 +386,5 @@ SM
386386
off=0 message begin
387387
off=4 len=1 span[url]="*"
388388
off=6 url complete
389-
off=24 error code=22 reason="Pause on PRI/Upgrade"
389+
off=24 error code=23 reason="Pause on PRI/Upgrade"
390390
```

0 commit comments

Comments
 (0)