har-export-trigger icon indicating copy to clipboard operation
har-export-trigger copied to clipboard

Option to disable including content in the HAR?

Open soulgalore opened this issue 7 years ago • 2 comments

Hi, one good feature in the future would be to disable getting the content inside of the HAR. Right now it includes everything in the content fields (that's great for debugging) but if it is possible to disable that from a config that would be great (it will make the HAR files so much smaller). Best Peter

soulgalore avatar Feb 21 '18 13:02 soulgalore

Yes, agree. The problem is that chrome.devtools.network.getHAR() method (as designed by chrome does always return the response body. There is no option to exclude it (and e.g. improve performance).

So, this extension can make sure that the response body is not in the result log (if some flag says so) by doing something like:

log.entries.forEach(entry => {
  delete entry.response.content.text;
})

It would look like as follows from the client perspective:

var options = {
  responseBody: false,   // Do not include response bodies
};

HAR.triggerExport(options).then(har => {
  // length should be smaller if response bodies are not included
  var length = JSON.stringify(har.log).length;
  var size = getFormattedSize(length);
  console.log("HAR log (" + size + ") ", har.log);
});

Would that help? Honza

janodvarko avatar Feb 27 '18 12:02 janodvarko

I don't maybe it doesn't matter if the API always includes? I manually wash it now depending on flags, and I think it's overkill then to include it the trigger?

soulgalore avatar May 17 '18 10:05 soulgalore