Skip to content

Commit 5db2ab5

Browse files
committed
Ensure httpVersion is now always defined in exposed data
1 parent 214da53 commit 5db2ab5

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/rules/requests/request-handlers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,7 @@ export class PassThroughHandler extends PassThroughHandlerDefinition {
932932
id: clientReq.id,
933933
protocol: protocol?.replace(':', '') ?? '',
934934
method: method,
935+
httpVersion: serverRes.httpVersion,
935936
url: reqUrl,
936937
destination: {
937938
hostname: hostname || 'localhost',

src/server/mockttp-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ ${await this.suggestRule(request)}`
10691069

10701070
const request: ClientError['request'] = {
10711071
...commonParams,
1072-
httpVersion: parsedRequest.httpVersion,
1072+
httpVersion: parsedRequest.httpVersion || '1.1',
10731073
method: parsedRequest.method,
10741074
protocol: parsedRequest.protocol,
10751075
url: parsedRequest.url,

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export interface Request {
5959
matchedRuleId?: string;
6060

6161
protocol: string;
62-
httpVersion?: string; // Like timingEvents - not set remotely with older servers
62+
httpVersion: string;
6363
method: string;
6464
url: string;
6565
path: string;
@@ -434,7 +434,7 @@ export interface ClientError {
434434

435435
// All of these are best guess, depending on what's parseable:
436436
protocol?: string;
437-
httpVersion?: string;
437+
httpVersion: string;
438438
method?: string;
439439
url?: string;
440440
path?: string;

0 commit comments

Comments
 (0)