HTTPClient.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="HTTPClient" inherits="Reference" category="Core" version="3.0.alpha.custom_build">
  3. <brief_description>
  4. Hyper-text transfer protocol client.
  5. </brief_description>
  6. <description>
  7. Hyper-text transfer protocol client. Supports SSL and SSL server certificate verification.
  8. Can be reused to connect to different hosts and make many requests.
  9. </description>
  10. <tutorials>
  11. </tutorials>
  12. <demos>
  13. </demos>
  14. <methods>
  15. <method name="close">
  16. <return type="void">
  17. </return>
  18. <description>
  19. Cloces the current connection, allows for reusal of [code]HTTPClient[/code].
  20. </description>
  21. </method>
  22. <method name="connect_to_host">
  23. <return type="int" enum="Error">
  24. </return>
  25. <argument index="0" name="host" type="String">
  26. </argument>
  27. <argument index="1" name="port" type="int">
  28. </argument>
  29. <argument index="2" name="use_ssl" type="bool" default="false">
  30. </argument>
  31. <argument index="3" name="verify_host" type="bool" default="true">
  32. </argument>
  33. <description>
  34. Connect to a host. This needs to be done before any requests are sent.
  35. The host should not have http:// prepended but will strip the protocol identifier if provided.
  36. verify_host will check the SSL identity of the host if set to true.
  37. </description>
  38. </method>
  39. <method name="get_connection" qualifiers="const">
  40. <return type="StreamPeer">
  41. </return>
  42. <description>
  43. Return current connection.
  44. </description>
  45. </method>
  46. <method name="get_response_body_length" qualifiers="const">
  47. <return type="int">
  48. </return>
  49. <description>
  50. Return the response's body length.
  51. </description>
  52. </method>
  53. <method name="get_response_code" qualifiers="const">
  54. <return type="int">
  55. </return>
  56. <description>
  57. Return the HTTP status code of the response.
  58. </description>
  59. </method>
  60. <method name="get_response_headers">
  61. <return type="PoolStringArray">
  62. </return>
  63. <description>
  64. Return the response headers.
  65. </description>
  66. </method>
  67. <method name="get_response_headers_as_dictionary">
  68. <return type="Dictionary">
  69. </return>
  70. <description>
  71. Returns all response headers as dictionary where the case-sensitivity of the keys and values is kept like the server delivers it. A value is a simple String, this string can have more than one value where "; " is used as separator.
  72. Structure: ("key":"value1; value2")
  73. Example: (content-length:12), (Content-Type:application/json; charset=UTF-8)
  74. </description>
  75. </method>
  76. <method name="get_status" qualifiers="const">
  77. <return type="int" enum="HTTPClient.Status">
  78. </return>
  79. <description>
  80. Returns a STATUS_* enum constant. Need to call [method poll] in order to get status updates.
  81. </description>
  82. </method>
  83. <method name="has_response" qualifiers="const">
  84. <return type="bool">
  85. </return>
  86. <description>
  87. Return whether this [code]HTTPClient[/code] has a response available.
  88. </description>
  89. </method>
  90. <method name="is_blocking_mode_enabled" qualifiers="const">
  91. <return type="bool">
  92. </return>
  93. <description>
  94. Return whether blocking mode is enabled.
  95. </description>
  96. </method>
  97. <method name="is_response_chunked" qualifiers="const">
  98. <return type="bool">
  99. </return>
  100. <description>
  101. Return whether this [code]HTTPClient[/code] has a response that is chunked.
  102. </description>
  103. </method>
  104. <method name="poll">
  105. <return type="int" enum="Error">
  106. </return>
  107. <description>
  108. This needs to be called in order to have any request processed. Check results with [method get_status]
  109. </description>
  110. </method>
  111. <method name="query_string_from_dict">
  112. <return type="String">
  113. </return>
  114. <argument index="0" name="fields" type="Dictionary">
  115. </argument>
  116. <description>
  117. Generates a GET/POST application/x-www-form-urlencoded style query string from a provided dictionary, e.g.:
  118. [codeblock]
  119. var fields = {"username": "user", "password": "pass"}
  120. String queryString = httpClient.query_string_from_dict(fields)
  121. returns:= "username=user&amp;password=pass"
  122. [/codeblock]
  123. </description>
  124. </method>
  125. <method name="read_response_body_chunk">
  126. <return type="PoolByteArray">
  127. </return>
  128. <description>
  129. Reads one chunk from the response.
  130. </description>
  131. </method>
  132. <method name="request">
  133. <return type="int" enum="Error">
  134. </return>
  135. <argument index="0" name="method" type="int" enum="HTTPClient.Method">
  136. </argument>
  137. <argument index="1" name="url" type="String">
  138. </argument>
  139. <argument index="2" name="headers" type="PoolStringArray">
  140. </argument>
  141. <argument index="3" name="body" type="String" default="&quot;&quot;">
  142. </argument>
  143. <description>
  144. Sends a request to the connected host. The url is what is normally behind the hostname, i.e. in [code]http://somehost.com/index.php[/code], url would be "index.php".
  145. Headers are HTTP request headers.
  146. To create a POST request with query strings to push to the server, do:
  147. [codeblock]
  148. var fields = {"username" : "user", "password" : "pass"}
  149. var queryString = httpClient.query_string_from_dict(fields)
  150. var headers = ["Content-Type: application/x-www-form-urlencoded", "Content-Length: " + str(queryString.length())]
  151. var result = httpClient.request(httpClient.METHOD_POST, "index.php", headers, queryString)
  152. [/codeblock]
  153. </description>
  154. </method>
  155. <method name="request_raw">
  156. <return type="int" enum="Error">
  157. </return>
  158. <argument index="0" name="method" type="int" enum="HTTPClient.Method">
  159. </argument>
  160. <argument index="1" name="url" type="String">
  161. </argument>
  162. <argument index="2" name="headers" type="PoolStringArray">
  163. </argument>
  164. <argument index="3" name="body" type="PoolByteArray">
  165. </argument>
  166. <description>
  167. Sends a raw request to the connected host. The url is what is normally behind the hostname, i.e. in [code]http://somehost.com/index.php[/code], url would be "index.php".
  168. Headers are HTTP request headers.
  169. Sends body raw, as a byte array, does not encode it in any way.
  170. </description>
  171. </method>
  172. <method name="set_blocking_mode">
  173. <return type="void">
  174. </return>
  175. <argument index="0" name="enabled" type="bool">
  176. </argument>
  177. <description>
  178. If set to true, execution will block until all data is read from the response.
  179. </description>
  180. </method>
  181. <method name="set_connection">
  182. <return type="void">
  183. </return>
  184. <argument index="0" name="connection" type="StreamPeer">
  185. </argument>
  186. <description>
  187. Set connection to use, for this client.
  188. </description>
  189. </method>
  190. <method name="set_read_chunk_size">
  191. <return type="void">
  192. </return>
  193. <argument index="0" name="bytes" type="int">
  194. </argument>
  195. <description>
  196. Sets the size of the buffer used and maximum bytes to read per iteration. see [method read_response_body_chunk]
  197. </description>
  198. </method>
  199. </methods>
  200. <constants>
  201. <constant name="METHOD_GET" value="0">
  202. </constant>
  203. <constant name="METHOD_HEAD" value="1">
  204. </constant>
  205. <constant name="METHOD_POST" value="2">
  206. </constant>
  207. <constant name="METHOD_PUT" value="3">
  208. </constant>
  209. <constant name="METHOD_DELETE" value="4">
  210. </constant>
  211. <constant name="METHOD_OPTIONS" value="5">
  212. </constant>
  213. <constant name="METHOD_TRACE" value="6">
  214. </constant>
  215. <constant name="METHOD_CONNECT" value="7">
  216. </constant>
  217. <constant name="METHOD_MAX" value="8">
  218. </constant>
  219. <constant name="STATUS_DISCONNECTED" value="0">
  220. </constant>
  221. <constant name="STATUS_RESOLVING" value="1">
  222. </constant>
  223. <constant name="STATUS_CANT_RESOLVE" value="2">
  224. </constant>
  225. <constant name="STATUS_CONNECTING" value="3">
  226. </constant>
  227. <constant name="STATUS_CANT_CONNECT" value="4">
  228. </constant>
  229. <constant name="STATUS_CONNECTED" value="5">
  230. </constant>
  231. <constant name="STATUS_REQUESTING" value="6">
  232. </constant>
  233. <constant name="STATUS_BODY" value="7">
  234. </constant>
  235. <constant name="STATUS_CONNECTION_ERROR" value="8">
  236. </constant>
  237. <constant name="STATUS_SSL_HANDSHAKE_ERROR" value="9">
  238. </constant>
  239. <constant name="RESPONSE_CONTINUE" value="100">
  240. </constant>
  241. <constant name="RESPONSE_SWITCHING_PROTOCOLS" value="101">
  242. </constant>
  243. <constant name="RESPONSE_PROCESSING" value="102">
  244. </constant>
  245. <constant name="RESPONSE_OK" value="200">
  246. </constant>
  247. <constant name="RESPONSE_CREATED" value="201">
  248. </constant>
  249. <constant name="RESPONSE_ACCEPTED" value="202">
  250. </constant>
  251. <constant name="RESPONSE_NON_AUTHORITATIVE_INFORMATION" value="203">
  252. </constant>
  253. <constant name="RESPONSE_NO_CONTENT" value="204">
  254. </constant>
  255. <constant name="RESPONSE_RESET_CONTENT" value="205">
  256. </constant>
  257. <constant name="RESPONSE_PARTIAL_CONTENT" value="206">
  258. </constant>
  259. <constant name="RESPONSE_MULTI_STATUS" value="207">
  260. </constant>
  261. <constant name="RESPONSE_IM_USED" value="226">
  262. </constant>
  263. <constant name="RESPONSE_MULTIPLE_CHOICES" value="300">
  264. </constant>
  265. <constant name="RESPONSE_MOVED_PERMANENTLY" value="301">
  266. </constant>
  267. <constant name="RESPONSE_FOUND" value="302">
  268. </constant>
  269. <constant name="RESPONSE_SEE_OTHER" value="303">
  270. </constant>
  271. <constant name="RESPONSE_NOT_MODIFIED" value="304">
  272. </constant>
  273. <constant name="RESPONSE_USE_PROXY" value="305">
  274. </constant>
  275. <constant name="RESPONSE_TEMPORARY_REDIRECT" value="307">
  276. </constant>
  277. <constant name="RESPONSE_BAD_REQUEST" value="400">
  278. </constant>
  279. <constant name="RESPONSE_UNAUTHORIZED" value="401">
  280. </constant>
  281. <constant name="RESPONSE_PAYMENT_REQUIRED" value="402">
  282. </constant>
  283. <constant name="RESPONSE_FORBIDDEN" value="403">
  284. </constant>
  285. <constant name="RESPONSE_NOT_FOUND" value="404">
  286. </constant>
  287. <constant name="RESPONSE_METHOD_NOT_ALLOWED" value="405">
  288. </constant>
  289. <constant name="RESPONSE_NOT_ACCEPTABLE" value="406">
  290. </constant>
  291. <constant name="RESPONSE_PROXY_AUTHENTICATION_REQUIRED" value="407">
  292. </constant>
  293. <constant name="RESPONSE_REQUEST_TIMEOUT" value="408">
  294. </constant>
  295. <constant name="RESPONSE_CONFLICT" value="409">
  296. </constant>
  297. <constant name="RESPONSE_GONE" value="410">
  298. </constant>
  299. <constant name="RESPONSE_LENGTH_REQUIRED" value="411">
  300. </constant>
  301. <constant name="RESPONSE_PRECONDITION_FAILED" value="412">
  302. </constant>
  303. <constant name="RESPONSE_REQUEST_ENTITY_TOO_LARGE" value="413">
  304. </constant>
  305. <constant name="RESPONSE_REQUEST_URI_TOO_LONG" value="414">
  306. </constant>
  307. <constant name="RESPONSE_UNSUPPORTED_MEDIA_TYPE" value="415">
  308. </constant>
  309. <constant name="RESPONSE_REQUESTED_RANGE_NOT_SATISFIABLE" value="416">
  310. </constant>
  311. <constant name="RESPONSE_EXPECTATION_FAILED" value="417">
  312. </constant>
  313. <constant name="RESPONSE_UNPROCESSABLE_ENTITY" value="422">
  314. </constant>
  315. <constant name="RESPONSE_LOCKED" value="423">
  316. </constant>
  317. <constant name="RESPONSE_FAILED_DEPENDENCY" value="424">
  318. </constant>
  319. <constant name="RESPONSE_UPGRADE_REQUIRED" value="426">
  320. </constant>
  321. <constant name="RESPONSE_INTERNAL_SERVER_ERROR" value="500">
  322. </constant>
  323. <constant name="RESPONSE_NOT_IMPLEMENTED" value="501">
  324. </constant>
  325. <constant name="RESPONSE_BAD_GATEWAY" value="502">
  326. </constant>
  327. <constant name="RESPONSE_SERVICE_UNAVAILABLE" value="503">
  328. </constant>
  329. <constant name="RESPONSE_GATEWAY_TIMEOUT" value="504">
  330. </constant>
  331. <constant name="RESPONSE_HTTP_VERSION_NOT_SUPPORTED" value="505">
  332. </constant>
  333. <constant name="RESPONSE_INSUFFICIENT_STORAGE" value="507">
  334. </constant>
  335. <constant name="RESPONSE_NOT_EXTENDED" value="510">
  336. </constant>
  337. </constants>
  338. </class>