title: mimic chrome download requests in postman
body: <p>In my chrome extension I am blocking user's downloads, and I am downloading the files in some other computer (some security app but it's not impotent for the post) based on the download url.</p>
  <p>The idea works fine for a lot of cases, for example if user trying to download the file <a href="http://www.orimi.com/pdf-test.pdf" rel="nofollow noreferrer">http://www.orimi.com/pdf-test.pdf</a> with his chrome browser, the the extension blocks the download, sends the url to some other server and the server downloads the link.</p>
  <p>I have problem with websites that asks some headers when downloading the file, is there a way to mimic the exact chrome request from other app?</p>
  <p>I tried using <code>chrome.webRequest.onBeforeSendHeaders.addListener</code> to get all request headers and then to use those headers to download the file from other place (I mean not via chrome but via poatman) and I get Unauthorized</p>
  <p>Here a small code example on the bacgroung script:</p>
  <pre><code>chrome.downloads.onCreated.addListener(function (e) {
      console.log(`============= begin onCreated =============`);
      console.log(e);
      console.log(`============= end onCreated =============`);
  });
  chrome.webRequest.onBeforeSendHeaders.addListener(
      function (details) {
          console.log(`============= begin onBeforeSendHeaders =============`);
          console.log(details);
          console.log(`============= end onBeforeSendHeaders =============`);
          return {
              requestHeaders: details.requestHeaders
          };
      }, {
          urls: [&quot;&lt;all_urls&gt;&quot;]
      },
      [&quot;blocking&quot;, &quot;requestHeaders&quot;]);
  </code></pre>
  <p>And when I am trying to download file from LinkedIn I get the output:</p>
  <pre><code>============= begin onBeforeSendHeaders =============
  background.js:27 {frameId: 0, initiator: &quot;https://www.linkedin.com&quot;, method: &quot;GET&quot;, parentFrameId: -1, requestHeaders: Array(7), …}frameId: 0initiator: &quot;https://www.linkedin.com&quot;method: &quot;GET&quot;parentFrameId: -1requestHeaders: Array(7)0: {name: &quot;Upgrade-Insecure-Requests&quot;, value: &quot;1&quot;}1: {name: &quot;User-Agent&quot;, value: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWeb…ML, like Gecko) Chrome/84.0.4147.89 Safari/537.36&quot;}2: {name: &quot;Accept&quot;, value: &quot;text/html,application/xhtml+xml,application/xml;q=…,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9&quot;}3: {name: &quot;Sec-Fetch-Site&quot;, value: &quot;same-origin&quot;}4: {name: &quot;Sec-Fetch-Mode&quot;, value: &quot;navigate&quot;}5: {name: &quot;Sec-Fetch-User&quot;, value: &quot;?1&quot;}6: {name: &quot;Sec-Fetch-Dest&quot;, value: &quot;document&quot;}length: 7__proto__: Array(0)requestId: &quot;305371&quot;tabId: 844timeStamp: 1596530356040.051type: &quot;main_frame&quot;url: &quot;https://www.linkedin.com/dms/C4D06AQGz1fU0o0r3ZQ/messaging-attachmentFile/0?m=AQLmTdbXe5dgKgAAAXO4axnTdJJLiaU6EnZbq_fhQzg_1697ToPaTbJ3jw&amp;ne=1&amp;v=beta&amp;t=QCDqVeorWfXEAgQBCQdo9hbEQrxwM97zqzCvLuBE2Cw#S6555100544749322240_500&quot;__proto__: Object
  background.js:28 ============= end onBeforeSendHeaders =============
  background.js:20 ============= begin onCreated =============
  background.js:21 {bytesReceived: 0, canResume: false, danger: &quot;safe&quot;, exists: true, fileSize: 0, …}bytesReceived: 0canResume: falsedanger: &quot;safe&quot;exists: truefileSize: 0filename: &quot;&quot;finalUrl: &quot;https://www.linkedin.com/dms/D5D06AQGz1fU0o0r3ZK/messaging-attachmentFile/0?m=AQLpTdbXe5dgKgAAAXO4axnTdJJLiaU6EnZbe_fhQzg_1697ToPaTbJ3jw&amp;ne=1&amp;v=beta&amp;t=QCDqVeorWfXEAgQBCQdo9hbEQrxwM97zqzCvLuBE2Cw#S6555100544749322246_500&quot;id: 7100incognito: falsemime: &quot;application/octet-stream&quot;paused: falsereferrer: &quot;https://www.linkedin.com/in/natali-melman-a785a349/&quot;startTime: &quot;2020-08-04T08:39:16.060Z&quot;state: &quot;in_progress&quot;totalBytes: 0url: &quot;https://www.linkedin.com/dms/D5D06AQGz1fU0o0r3ZK/messaging-attachmentFile/0?m=AQLpTdbXe5dgKgAAAXO4axnTdJJLiaU6EnZbe_fhQzg_1697ToPaTbJ3jw&amp;ne=1&amp;v=beta&amp;t=QCDqVeorWfXEAgQBCQdo9hbEQrxwM97zqzCvLuBE2Cw#S6555100544749322256_500&quot;__proto__: Object
  background.js:22 ============= end onCreated =============
  </code></pre>
  <p>I tried to mimic this exact request in postman (same header, parameters etc) but I get 401 error code</p>