Skip to content

inspector: add mimeType and charset support to Network.Response #58192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

islandryu
Copy link
Contributor

Refs: #53946

It supports the mimeType and charset defined in Network.Response.
https://chromedevtools.github.io/devtools-protocol/tot/Network/#type-Response

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol needs-ci PRs that need a full CI run. labels May 6, 2025
Comment on lines +127 to +130
common.mustCall(({ params }) => {
assert.strictEqual(params.response.mimeType, '');
assert.strictEqual(params.response.charset, '');
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the Content-Type header is not set, Chromium also assigns an empty string.

Copy link

codecov bot commented May 6, 2025

Codecov Report

Attention: Patch coverage is 85.71429% with 6 lines in your changes missing coverage. Please review.

Project coverage is 90.12%. Comparing base (5f48fdd) to head (f29d215).
Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
src/inspector/network_agent.cc 50.00% 2 Missing and 2 partials ⚠️
lib/internal/inspector/network_http.js 93.33% 1 Missing ⚠️
lib/internal/inspector/network_undici.js 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58192      +/-   ##
==========================================
- Coverage   90.15%   90.12%   -0.03%     
==========================================
  Files         630      629       -1     
  Lines      186756   186670      -86     
  Branches    36652    36635      -17     
==========================================
- Hits       168361   168231     -130     
- Misses      11192    11215      +23     
- Partials     7203     7224      +21     
Files with missing lines Coverage Δ
lib/internal/inspector/network_http.js 94.55% <93.33%> (-0.14%) ⬇️
lib/internal/inspector/network_undici.js 93.75% <94.73%> (+0.13%) ⬆️
src/inspector/network_agent.cc 61.19% <50.00%> (-0.47%) ⬇️

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

const contentType = contentTypeKeyIndex !== -1 ? response.headers[contentTypeKeyIndex + 1].toString() : '';
const mimeTypeObj = new MIMEType(contentType);
mimeType = mimeTypeObj.essence || '';
charset = mimeTypeObj.params.get('charset');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Charset can be undefined/null if this does not exist. I don't think we want that.

Copy link
Contributor Author

@islandryu islandryu May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I overlooked this case.
Like mimeType, I’ve set it to an empty string.

})
);
}),
2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems indented out of order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants