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