Skip to content

Commit 3aef0fe

Browse files
authored
v1.6.0
2 parents c9e485c + 936bf91 commit 3aef0fe

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

AwaitableHTTPRequest.gd

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class_name AwaitableHTTPRequest
22
extends HTTPRequest
3-
## Awaitable HTTP Request Node v1.5.2 by swark1n
3+
## Awaitable HTTP Request Node v1.6.0 by swark1n & [url=https://github.com/Swarkin/Godot-AwaitableHTTPRequest/graphs/contributors]contributors[/url].
44

55
signal request_finished ## Emits once the current request finishes, right after [member is_requesting] is set to false.
66
var is_requesting := false ## Whether the node is busy performing a request.
@@ -10,15 +10,14 @@ class HTTPResult extends RefCounted:
1010
var _error: Error ## Returns the [method HTTPRequest.request] error, [constant Error.OK] otherwise.
1111
var _result: HTTPRequest.Result ## Returns the [annotation HTTPRequest] error, [constant HTTPRequest.RESULT_SUCCESS] otherwise.
1212
var success: bool: ## Checks whether [member _error] and [member _result] aren't in an error state.[br][b]Note:[/b] This does not return false if [member status_code] is >= 400, see [code]https://developer.mozilla.org/en-US/docs/Web/HTTP/Status[/code].
13-
set(v): pass
1413
get: return true if (_error == OK and _result == HTTPRequest.RESULT_SUCCESS) else false
1514

1615
var status_code: int ## The response status code.
1716
var headers: Dictionary ## The response headers.
18-
var body: String ## The response body as a String.
19-
var body_raw: PackedByteArray ## The response body as a PackedByteArray.
17+
var body: String: ## The response body as a [String].
18+
get: return body_raw.get_string_from_utf8()
19+
var body_raw: PackedByteArray ## The response body as a [PackedByteArray].
2020
var json: Variant: ## Attempt to parse [member body] into a [Dictionary] or [Array], returns null on failure.
21-
set(v): pass
2221
get: return JSON.parse_string(body)
2322

2423
## Constructs a new [AwaitableHTTPRequest.HTTPResult] from an [enum @GlobalScope.Error] code.
@@ -33,8 +32,7 @@ class HTTPResult extends RefCounted:
3332
@warning_ignore('unsafe_cast') h._result = a[0] as HTTPRequest.Result
3433
@warning_ignore('unsafe_cast') h.status_code = a[1] as int
3534
@warning_ignore('unsafe_cast') h.headers = _headers_to_dict(a[2] as PackedStringArray)
36-
@warning_ignore('unsafe_cast') h.body = (a[3] as PackedByteArray).get_string_from_utf8()
37-
@warning_ignore('unsafe_cast') h.body_raw = (a[3] as PackedByteArray)
35+
@warning_ignore('unsafe_cast') h.body_raw = a[3] as PackedByteArray
3836
return h
3937

4038
static func _headers_to_dict(headers_arr: PackedStringArray) -> Dictionary:

0 commit comments

Comments
 (0)