Response.hx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (C)2005-2019 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. // This file is generated from mozilla\Response.webidl. Do not edit!
  23. package js.html;
  24. import js.lib.Promise;
  25. /**
  26. The `Response` interface of the Fetch API represents the response to a request.
  27. Documentation [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/API/Response$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
  28. @see <https://developer.mozilla.org/en-US/docs/Web/API/Response>
  29. **/
  30. @:native("Response")
  31. extern class Response {
  32. /**
  33. Returns a new `Response` object associated with a network error.
  34. **/
  35. static function error() : Response;
  36. /**
  37. Creates a new response with a different URL.
  38. @throws DOMError
  39. **/
  40. static function redirect( url : String, status : Int = 302 ) : Response;
  41. /**
  42. Contains the type of the response (e.g., `basic`, `cors`).
  43. **/
  44. var type(default,null) : ResponseType;
  45. /**
  46. Contains the URL of the response.
  47. **/
  48. var url(default,null) : String;
  49. /**
  50. Indicates whether or not the response is the result of a redirect; that is, its URL list has more than one entry.
  51. **/
  52. var redirected(default,null) : Bool;
  53. /**
  54. Contains the status code of the response (e.g., `200` for a success).
  55. **/
  56. var status(default,null) : Int;
  57. /**
  58. Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
  59. **/
  60. var ok(default,null) : Bool;
  61. /**
  62. Contains the status message corresponding to the status code (e.g., `OK` for `200`).
  63. **/
  64. var statusText(default,null) : String;
  65. /**
  66. Contains the `Headers` object associated with the response.
  67. **/
  68. var headers(default,null) : Headers;
  69. var bodyUsed(default,null) : Bool;
  70. /** @throws DOMError */
  71. @:overload( function( ?body : js.lib.ArrayBufferView, ?init : ResponseInit) : Response {} )
  72. @:overload( function( ?body : js.lib.ArrayBuffer, ?init : ResponseInit) : Response {} )
  73. @:overload( function( ?body : FormData, ?init : ResponseInit) : Response {} )
  74. @:overload( function( ?body : URLSearchParams, ?init : ResponseInit) : Response {} )
  75. @:overload( function( ?body : Dynamic/*MISSING ReadableStream*/, ?init : ResponseInit) : Response {} )
  76. @:overload( function( ?body : String, ?init : ResponseInit) : Response {} )
  77. function new( ?body : Blob, ?init : ResponseInit ) : Void;
  78. /**
  79. Creates a clone of a `Response` object.
  80. @throws DOMError
  81. **/
  82. function clone() : Response;
  83. /** @throws DOMError */
  84. function arrayBuffer() : Promise<js.lib.ArrayBuffer>;
  85. /** @throws DOMError */
  86. function blob() : Promise<Blob>;
  87. /** @throws DOMError */
  88. function formData() : Promise<FormData>;
  89. /** @throws DOMError */
  90. function json() : Promise<Dynamic>;
  91. /** @throws DOMError */
  92. function text() : Promise<String>;
  93. }