Skip to content

browser.webRequest.filterResponseData ondata error #364

Closed
@admimistrator

Description

@admimistrator

https://github.com/mdn/webextensions-examples/tree/master/http-response
code :

function listener(details) {
  var filter = browser.webRequest.filterResponseData(details.requestId);
  var decoder = new TextDecoder("utf-8");
  var encoder = new TextEncoder();

  filter.ondata = event => {
	
    var str = decoder.decode(event.data, {stream: true});
   console.log( str.length, str);
    filter.write(encoder.encode(str));
    filter.disconnect();
  }

  return {};
}

browser.webRequest.onBeforeRequest.addListener(
  listener,
  {urls: ["<all_urls>"], types: ["xmlhttprequest"]},
  ["blocking"]
);

console.log( str.length, str);
sometimes, the str is fragmentary .
for example,like this pic:
qq 20180722004155

"alig" it's not the end of response ,but it's end...

the real response is :
qq 20180722004826

Metadata

Metadata

Assignees

No one assigned

    Labels

    exampleNew or updated exampleidleIssues and pull requests with no activity for three months.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions