mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-24 11:17:26 -04:00
cancel http request
This commit is contained in:
parent
e31fa51046
commit
db671ac9bf
3 changed files with 23 additions and 4 deletions
|
@ -10,6 +10,7 @@ class_name PromptResults
|
|||
var prompt_size: float
|
||||
var result_str: String
|
||||
var last_query: String
|
||||
var cancel_callbacks: Array = []
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -48,11 +49,15 @@ func prompt_request(query: String) -> void:
|
|||
result_str = body.get_string_from_utf8()
|
||||
else: Debug.logclr("Request prompt failed. Code " + str(code), Color.RED)
|
||||
|
||||
var err = await Backend.request(url, callback)
|
||||
var err = await Backend.request(url, callback, {}, HTTPClient.METHOD_GET, cancel_callbacks)
|
||||
if err != HTTPRequest.RESULT_SUCCESS: Debug.logclr("Cannot send request prompt", Color.RED)
|
||||
|
||||
|
||||
func clear() -> void:
|
||||
for callback in cancel_callbacks:
|
||||
callback.call()
|
||||
cancel_callbacks.clear()
|
||||
|
||||
for child in get_children():
|
||||
child.queue_free()
|
||||
remove_child(child)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue