Skip to content

Commit

Permalink
Requests have headers
Browse files Browse the repository at this point in the history
  • Loading branch information
A5hleyRich committed Apr 6, 2024
1 parent 3b9662b commit 79e268b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,14 @@ public function receiveTiming(int $precision = 2): float
{
return round($this->request['timings']['receive'], $precision);
}

public function requestHeaders(): array
{
return $this->request['request']['headers'];
}

public function responseHeaders(): array
{
return $this->request['response']['headers'];
}
}
16 changes: 16 additions & 0 deletions tests/Unit/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,19 @@
->and($this->request->receiveTiming(0))->toEqual(47)
->and($this->request->receiveTiming(3))->toEqual(46.900);
});

test('request headers', function () {
expect($this->request->requestHeaders())->toBeArray()
->and($this->request->requestHeaders()[0])->toMatchArray([
'name' => ':authority',
'value' => 'github.com',
]);
});

test('request response headers', function () {
expect($this->request->responseHeaders())->toBeArray()
->and($this->request->responseHeaders()[0])->toMatchArray([
'name' => 'accept-ranges',
'value' => 'bytes',
]);
});

0 comments on commit 79e268b

Please sign in to comment.