HttpClient.js 1.3 KB

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