uniapp,h5

polling-xhr.node.js 732B

123456789101112131415161718
  1. import * as XMLHttpRequestModule from "xmlhttprequest-ssl";
  2. import { BaseXHR, Request } from "./polling-xhr.js";
  3. const XMLHttpRequest = XMLHttpRequestModule.default || XMLHttpRequestModule;
  4. /**
  5. * HTTP long-polling based on the `XMLHttpRequest` object provided by the `xmlhttprequest-ssl` package.
  6. *
  7. * Usage: Node.js, Deno (compat), Bun (compat)
  8. *
  9. * @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
  10. */
  11. export class XHR extends BaseXHR {
  12. request(opts = {}) {
  13. var _a;
  14. Object.assign(opts, { xd: this.xd, cookieJar: (_a = this.socket) === null || _a === void 0 ? void 0 : _a._cookieJar }, this.opts);
  15. return new Request((opts) => new XMLHttpRequest(opts), this.uri(), opts);
  16. }
  17. }