Getting content of response on WebExtension devtools API









up vote
0
down vote

favorite












I'm trying to get the content of some background requests made while loading a website. I decided to use the devtools API, so I'm doing something like:



function handleRequestFinished(request) 
request.getContent().then(content =>
// do something with content here
);

}
browser.devtools.network.onRequestFinished.addListener(handleRequestFinished);


Not exactly my code, but just a skeleton of how this is supposed to be done if we follow the docs1.



So what happens is, for some urls I get as content a list like [null, null]. I suspect this is a bug or a permissions thing (maybe there are special permissions needed to get the content of a request if it is 3rd party/https/-add whatever arcane condition Mozilla considered here-).



I'm considering switching to webRequest, but in any case, if someone has a clue about what is happening here I would very much appreciate your help.



Update: Seems the problem is more related to big binary files. This API returns the base64 representation of binary files, and it seems that at some size it just stops returning anything. I've tried setting devtools.netmonitor.responseBodyLimit with no luck.



PS: On the network tab, the content of those responses appears just fine.. The content on the network tab is truncated. Same as the content obtained through webRequest API. The only way to get the full response is by doing a curl...










share|improve this question



























    up vote
    0
    down vote

    favorite












    I'm trying to get the content of some background requests made while loading a website. I decided to use the devtools API, so I'm doing something like:



    function handleRequestFinished(request) 
    request.getContent().then(content =>
    // do something with content here
    );

    }
    browser.devtools.network.onRequestFinished.addListener(handleRequestFinished);


    Not exactly my code, but just a skeleton of how this is supposed to be done if we follow the docs1.



    So what happens is, for some urls I get as content a list like [null, null]. I suspect this is a bug or a permissions thing (maybe there are special permissions needed to get the content of a request if it is 3rd party/https/-add whatever arcane condition Mozilla considered here-).



    I'm considering switching to webRequest, but in any case, if someone has a clue about what is happening here I would very much appreciate your help.



    Update: Seems the problem is more related to big binary files. This API returns the base64 representation of binary files, and it seems that at some size it just stops returning anything. I've tried setting devtools.netmonitor.responseBodyLimit with no luck.



    PS: On the network tab, the content of those responses appears just fine.. The content on the network tab is truncated. Same as the content obtained through webRequest API. The only way to get the full response is by doing a curl...










    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm trying to get the content of some background requests made while loading a website. I decided to use the devtools API, so I'm doing something like:



      function handleRequestFinished(request) 
      request.getContent().then(content =>
      // do something with content here
      );

      }
      browser.devtools.network.onRequestFinished.addListener(handleRequestFinished);


      Not exactly my code, but just a skeleton of how this is supposed to be done if we follow the docs1.



      So what happens is, for some urls I get as content a list like [null, null]. I suspect this is a bug or a permissions thing (maybe there are special permissions needed to get the content of a request if it is 3rd party/https/-add whatever arcane condition Mozilla considered here-).



      I'm considering switching to webRequest, but in any case, if someone has a clue about what is happening here I would very much appreciate your help.



      Update: Seems the problem is more related to big binary files. This API returns the base64 representation of binary files, and it seems that at some size it just stops returning anything. I've tried setting devtools.netmonitor.responseBodyLimit with no luck.



      PS: On the network tab, the content of those responses appears just fine.. The content on the network tab is truncated. Same as the content obtained through webRequest API. The only way to get the full response is by doing a curl...










      share|improve this question















      I'm trying to get the content of some background requests made while loading a website. I decided to use the devtools API, so I'm doing something like:



      function handleRequestFinished(request) 
      request.getContent().then(content =>
      // do something with content here
      );

      }
      browser.devtools.network.onRequestFinished.addListener(handleRequestFinished);


      Not exactly my code, but just a skeleton of how this is supposed to be done if we follow the docs1.



      So what happens is, for some urls I get as content a list like [null, null]. I suspect this is a bug or a permissions thing (maybe there are special permissions needed to get the content of a request if it is 3rd party/https/-add whatever arcane condition Mozilla considered here-).



      I'm considering switching to webRequest, but in any case, if someone has a clue about what is happening here I would very much appreciate your help.



      Update: Seems the problem is more related to big binary files. This API returns the base64 representation of binary files, and it seems that at some size it just stops returning anything. I've tried setting devtools.netmonitor.responseBodyLimit with no luck.



      PS: On the network tab, the content of those responses appears just fine.. The content on the network tab is truncated. Same as the content obtained through webRequest API. The only way to get the full response is by doing a curl...







      firefox firefox-addon firefox-webextensions






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 9:10

























      asked Nov 10 at 20:08









      dyeray

      798312




      798312



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242979%2fgetting-content-of-response-on-webextension-devtools-api%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242979%2fgetting-content-of-response-on-webextension-devtools-api%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          政党