Skip to content

Commit

Permalink
🐛 (fix) Include early hints requests (#118)
Browse files Browse the repository at this point in the history
* Include earlyHints served from cache.

#115

* Remove bluebird, replace with native promises

* Map from* response data

* Add example containing early hints requests

* Add test to capture early hints

* Format & lint fix

---------

Co-authored-by: soulgalore <[email protected]>
  • Loading branch information
benschwarz and soulgalore authored Jul 5, 2024
1 parent 7a821bb commit e66459b
Show file tree
Hide file tree
Showing 5 changed files with 37,545 additions and 56 deletions.
8 changes: 6 additions & 2 deletions lib/entryFromResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ module.exports = function(entry, response, page, options) {
bodySize: -1,
cookies,
headers,
_transferSize: response.encodedDataLength
_transferSize: response.encodedDataLength,
fromDiskCache: response.fromDiskCache || false,
fromEarlyHints: response.fromEarlyHints || false,
fromServiceWorker: response.fromServiceWorker || false,
fromPrefetchCache: response.fromPrefetchCache || false
};

const locationHeaderValue = getHeaderValue(responseHeaders, 'Location');
Expand All @@ -90,7 +94,7 @@ module.exports = function(entry, response, page, options) {

entry.request.httpVersion = response.protocol;

if (response.fromDiskCache === true) {
if (response.fromDiskCache === true && !response.fromEarlyHints === true) {
if (isHttp1x(response.protocol)) {
// In http2 headers are compressed, so calculating size from headers text wouldn't be correct.
entry.response.headersSize = calculateResponseHeaderSize(response);
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"license": "MIT",
"devDependencies": {
"ava": "~0.25.0",
"bluebird": "~3.5.1",
"eslint": "~4.18.2",
"eslint-config-prettier": "~2.9.0",
"eslint-plugin-prettier": "~2.6.0",
Expand Down
Loading

0 comments on commit e66459b

Please sign in to comment.