AjaxResponse.js 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.AjaxResponse = void 0;
  4. var getXHRResponse_1 = require("./getXHRResponse");
  5. var AjaxResponse = (function () {
  6. function AjaxResponse(originalEvent, xhr, request, type) {
  7. if (type === void 0) { type = 'download_load'; }
  8. this.originalEvent = originalEvent;
  9. this.xhr = xhr;
  10. this.request = request;
  11. this.type = type;
  12. var status = xhr.status, responseType = xhr.responseType;
  13. this.status = status !== null && status !== void 0 ? status : 0;
  14. this.responseType = responseType !== null && responseType !== void 0 ? responseType : '';
  15. var allHeaders = xhr.getAllResponseHeaders();
  16. this.responseHeaders = allHeaders
  17. ?
  18. allHeaders.split('\n').reduce(function (headers, line) {
  19. var index = line.indexOf(': ');
  20. headers[line.slice(0, index)] = line.slice(index + 2);
  21. return headers;
  22. }, {})
  23. : {};
  24. this.response = getXHRResponse_1.getXHRResponse(xhr);
  25. var loaded = originalEvent.loaded, total = originalEvent.total;
  26. this.loaded = loaded;
  27. this.total = total;
  28. }
  29. return AjaxResponse;
  30. }());
  31. exports.AjaxResponse = AjaxResponse;
  32. //# sourceMappingURL=AjaxResponse.js.map