HTTPRequest.xml 5.2 KB

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