@@ -51,10 +51,7 @@ It will connect and fetch a website.
5151 while http.get_status() == HTTPClient.STATUS_CONNECTING or http.get_status() == HTTPClient.STATUS_RESOLVING:
5252 http.poll()
5353 print("Connecting...")
54- if not OS.has_feature("web"):
55- OS.delay_msec(500)
56- else:
57- yield(Engine.get_main_loop(), "idle_frame")
54+ await get_tree().process_frame
5855
5956 assert(http.get_status() == HTTPClient.STATUS_CONNECTED) # Check if the connection was made successfully.
6057
@@ -71,12 +68,7 @@ It will connect and fetch a website.
7168 # Keep polling for as long as the request is being processed.
7269 http.poll()
7370 print("Requesting...")
74- if OS.has_feature("web"):
75- # Synchronous HTTP requests are not supported on the web,
76- # so wait for the next main loop iteration.
77- yield(Engine.get_main_loop(), "idle_frame")
78- else:
79- OS.delay_msec(500)
71+ await get_tree().process_frame
8072
8173 assert(http.get_status() == HTTPClient.STATUS_BODY or http.get_status() == HTTPClient.STATUS_CONNECTED) # Make sure request finished well.
8274
@@ -109,11 +101,7 @@ It will connect and fetch a website.
109101 # Get a chunk.
110102 var chunk = http.read_response_body_chunk()
111103 if chunk.size() == 0:
112- if not OS.has_feature("web"):
113- # Got nothing, wait for buffers to fill a bit.
114- OS.delay_usec(1000)
115- else:
116- yield(Engine.get_main_loop(), "idle_frame")
104+ await get_tree().process_frame
117105 else:
118106 rb = rb + chunk # Append to read buffer.
119107 # Done!
0 commit comments