HttpClient.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. // Licensed to the .NET Foundation under one or more agreements.
  3. // The .NET Foundation licenses this file to you under the MIT license.
  4. Object.defineProperty(exports, "__esModule", { value: true });
  5. exports.HttpClient = exports.HttpResponse = void 0;
  6. /** Represents an HTTP response. */
  7. class HttpResponse {
  8. constructor(statusCode, statusText, content) {
  9. this.statusCode = statusCode;
  10. this.statusText = statusText;
  11. this.content = content;
  12. }
  13. }
  14. exports.HttpResponse = HttpResponse;
  15. /** Abstraction over an HTTP client.
  16. *
  17. * This class provides an abstraction over an HTTP client so that a different implementation can be provided on different platforms.
  18. */
  19. class HttpClient {
  20. get(url, options) {
  21. return this.send({
  22. ...options,
  23. method: "GET",
  24. url,
  25. });
  26. }
  27. post(url, options) {
  28. return this.send({
  29. ...options,
  30. method: "POST",
  31. url,
  32. });
  33. }
  34. delete(url, options) {
  35. return this.send({
  36. ...options,
  37. method: "DELETE",
  38. url,
  39. });
  40. }
  41. /** Gets all cookies that apply to the specified URL.
  42. *
  43. * @param url The URL that the cookies are valid for.
  44. * @returns {string} A string containing all the key-value cookie pairs for the specified URL.
  45. */
  46. // @ts-ignore
  47. getCookieString(url) {
  48. return "";
  49. }
  50. }
  51. exports.HttpClient = HttpClient;
  52. //# sourceMappingURL=HttpClient.js.map