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S,QAAQ,EAAE;AACvB,gBAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC7B,eAAO,QAAQ,CAAC;OACjB,CAAC,SACI,CAAC,UAAS,KAAK,EAAE;AACrB,gBAAQ,CAAC,KAAK,GAAM,KAAK,CAAC;AAC1B,gBAAQ,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC3C,cAAM,KAAK,CAAC;OACb,CAAC,CAAC;KACN;;;;;;;WAMG,gBAA0B;UAAzB,MAAM,yDAAG,OAAO,CAAC,MAAM;;AAC1B,UAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EACnB,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,KAE/B,IAAI,CAAC,OAAO,CAAC,UAAA,QAAQ;eAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;OAAA,CAAC,CAAC;KACnD;;;SApCG,SAAS;GAAS,KAAK;;AA0C7B,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC","file":"resources.js","sourcesContent":["// History of resources loaded by window.\n\nconst Fetch = require('./fetch');\n\n\n// Each resource is associated with request, and on completion response or error.\nclass Resource {\n\n  constructor({ request }) {\n    this.request  = request;\n    this.error    = null;\n    this.response = null;\n  }\n\n  // The URL of this resource\n  get url() {\n    return (this.response && this.response.url) || this.request.url;\n  }\n\n  // Dump the resource to output stream/stdout\n  dump(output = process.stdout) {\n    const { request, response, error } = this;\n    // Write summary request/response header\n    if (response) {\n      const elapsed = response.time - request.time;\n      output.write(`${request.method} ${this.url} - ${response.status} ${response.statusText} - ${elapsed}ms\\n`);\n    } else\n      output.write(`${request.method} ${this.url}\\n`);\n\n    // If response, write out response headers and sample of document entity\n    // If error, write out the error message\n    // Otherwise, indicate this is a pending request\n    if (response) {\n      if (response._redirectCount)\n        output.write(`  Followed ${response._redirectCount} redirects\\n`);\n      for (let [name, value] of response.headers)\n        output.write(`  ${name}: ${value}\\n`);\n      output.write('\\n');\n      const sample = response.body\n        .slice(0, 250)\n        .toString('utf8')\n        .split('\\n')\n        .map(line => `  ${line}`)\n        .join('\\n');\n      output.write(sample);\n    } else if (error)\n      output.write(`  Error: ${error.message}\\n`);\n    else\n      output.write(`  Pending since ${new Date(request.time)}\\n`);\n    // Keep them separated\n    output.write('\\n\\n');\n  }\n\n}\n\n\n// Each window has a resources object that provides the means for retrieving\n// resources and a list of all retrieved resources.\n//\n// The object is an array, and its elements are the resources.\nclass Resources extends Array {\n\n  constructor(window) {\n    super();\n    this._browser = window.browser;\n  }\n\n\n  _fetch(input, init) {\n    const pipeline  = this._browser.pipeline;\n    const request   = new Fetch.Request(input, init);\n    const resource  = new Resource({ request });\n    this.push(resource);\n\n    return pipeline\n      ._fetch(request)\n      .then(function(response) {\n        resource.response = response;\n        return response;\n      })\n      .catch(function(error) {\n        resource.error    = error;\n        resource.response = Fetch.Response.error();\n        throw error;\n      });\n  }\n\n\n  // Human readable resource listing.\n  //\n  // output - Write to this stream (optional)\n  dump(output = process.stdout) {\n    if (this.length === 0)\n      output.write('No resources\\n');\n    else\n      this.forEach(resource => resource.dump(output));\n  }\n\n}\n\n\n\nmodule.exports = Resources;\n\n"]}