HTTPRequest.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="HTTPRequest" inherits="Node" category="Core" version="3.1">
  3. <brief_description>
  4. A node with the ability to send HTTP requests.
  5. </brief_description>
  6. <description>
  7. A node with the ability to send HTTP requests. Uses [HTTPClient] internally.
  8. Can be used to make HTTP requests, i.e. download or upload files or web content via HTTP.
  9. </description>
  10. <tutorials>
  11. <link>https://docs.godotengine.org/en/latest/tutorials/networking/ssl_certificates.html</link>
  12. </tutorials>
  13. <demos>
  14. </demos>
  15. <methods>
  16. <method name="cancel_request">
  17. <return type="void">
  18. </return>
  19. <description>
  20. Cancels the current request.
  21. </description>
  22. </method>
  23. <method name="get_body_size" qualifiers="const">
  24. <return type="int">
  25. </return>
  26. <description>
  27. Returns the response body length.
  28. </description>
  29. </method>
  30. <method name="get_downloaded_bytes" qualifiers="const">
  31. <return type="int">
  32. </return>
  33. <description>
  34. Returns the amount of bytes this HTTPRequest downloaded.
  35. </description>
  36. </method>
  37. <method name="get_http_client_status" qualifiers="const">
  38. <return type="int" enum="HTTPClient.Status">
  39. </return>
  40. <description>
  41. Returns the current status of the underlying [HTTPClient]. See [code]STATUS_*[/code] enum on [HTTPClient].
  42. </description>
  43. </method>
  44. <method name="request">
  45. <return type="int" enum="Error">
  46. </return>
  47. <argument index="0" name="url" type="String">
  48. </argument>
  49. <argument index="1" name="custom_headers" type="PoolStringArray" default="PoolStringArray( )">
  50. </argument>
  51. <argument index="2" name="ssl_validate_domain" type="bool" default="true">
  52. </argument>
  53. <argument index="3" name="method" type="int" enum="HTTPClient.Method" default="0">
  54. </argument>
  55. <argument index="4" name="request_data" type="String" default="&quot;&quot;">
  56. </argument>
  57. <description>
  58. Creates request on the underlying [HTTPClient]. If there is no configuration errors, it tries to connect using [method HTTPClient.connect_to_host] and passes parameters onto [method HTTPClient.request].
  59. Returns [code]OK[/code] if request is successfully created. (Does not imply that the server has responded), [code]ERR_UNCONFIGURED[/code] if not in the tree, [code]ERR_BUSY[/code] if still processing previous request, [code]ERR_INVALID_PARAMETER[/code] if given string is not a valid URL format, or [code]ERR_CANT_CONNECT[/code] if not using thread and the [HTTPClient] cannot connect to host.
  60. </description>
  61. </method>
  62. </methods>
  63. <members>
  64. <member name="body_size_limit" type="int" setter="set_body_size_limit" getter="get_body_size_limit">
  65. Maximum allowed size for response bodies.
  66. </member>
  67. <member name="download_file" type="String" setter="set_download_file" getter="get_download_file">
  68. The file to download into. Will output any received file into it.
  69. </member>
  70. <member name="max_redirects" type="int" setter="set_max_redirects" getter="get_max_redirects">
  71. Maximum number of allowed redirects.
  72. </member>
  73. <member name="use_threads" type="bool" setter="set_use_threads" getter="is_using_threads">
  74. If [code]true[/code], multithreading is used to improve performance.
  75. </member>
  76. </members>
  77. <signals>
  78. <signal name="request_completed">
  79. <argument index="0" name="result" type="int">
  80. </argument>
  81. <argument index="1" name="response_code" type="int">
  82. </argument>
  83. <argument index="2" name="headers" type="PoolStringArray">
  84. </argument>
  85. <argument index="3" name="body" type="PoolByteArray">
  86. </argument>
  87. <description>
  88. This signal is emitted upon request completion.
  89. </description>
  90. </signal>
  91. </signals>
  92. <constants>
  93. <constant name="RESULT_SUCCESS" value="0" enum="Result">
  94. Request successful.
  95. </constant>
  96. <constant name="RESULT_CHUNKED_BODY_SIZE_MISMATCH" value="1" enum="Result">
  97. </constant>
  98. <constant name="RESULT_CANT_CONNECT" value="2" enum="Result">
  99. Request failed while connecting.
  100. </constant>
  101. <constant name="RESULT_CANT_RESOLVE" value="3" enum="Result">
  102. Request failed while resolving.
  103. </constant>
  104. <constant name="RESULT_CONNECTION_ERROR" value="4" enum="Result">
  105. Request failed due to connection (read/write) error.
  106. </constant>
  107. <constant name="RESULT_SSL_HANDSHAKE_ERROR" value="5" enum="Result">
  108. Request failed on SSL handshake.
  109. </constant>
  110. <constant name="RESULT_NO_RESPONSE" value="6" enum="Result">
  111. Request does not have a response (yet).
  112. </constant>
  113. <constant name="RESULT_BODY_SIZE_LIMIT_EXCEEDED" value="7" enum="Result">
  114. Request exceeded its maximum size limit, see [member body_size_limit].
  115. </constant>
  116. <constant name="RESULT_REQUEST_FAILED" value="8" enum="Result">
  117. Request failed. (Unused)
  118. </constant>
  119. <constant name="RESULT_DOWNLOAD_FILE_CANT_OPEN" value="9" enum="Result">
  120. HTTPRequest couldn't open the download file.
  121. </constant>
  122. <constant name="RESULT_DOWNLOAD_FILE_WRITE_ERROR" value="10" enum="Result">
  123. HTTPRequest couldn't write to the download file.
  124. </constant>
  125. <constant name="RESULT_REDIRECT_LIMIT_REACHED" value="11" enum="Result">
  126. Request reached its maximum redirect limit, see [member max_redirects].
  127. </constant>
  128. </constants>
  129. </class>