Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions tutorials/networking/http_client_class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ It will connect and fetch a website.
while http.get_status() == HTTPClient.STATUS_CONNECTING or http.get_status() == HTTPClient.STATUS_RESOLVING:
http.poll()
print("Connecting...")
if not OS.has_feature("web"):
OS.delay_msec(500)
else:
yield(Engine.get_main_loop(), "idle_frame")
await get_tree().process_frame

assert(http.get_status() == HTTPClient.STATUS_CONNECTED) # Check if the connection was made successfully.

Expand All @@ -71,12 +68,7 @@ It will connect and fetch a website.
# Keep polling for as long as the request is being processed.
http.poll()
print("Requesting...")
if OS.has_feature("web"):
# Synchronous HTTP requests are not supported on the web,
# so wait for the next main loop iteration.
yield(Engine.get_main_loop(), "idle_frame")
else:
OS.delay_msec(500)
await get_tree().process_frame

assert(http.get_status() == HTTPClient.STATUS_BODY or http.get_status() == HTTPClient.STATUS_CONNECTED) # Make sure request finished well.

Expand Down Expand Up @@ -109,11 +101,7 @@ It will connect and fetch a website.
# Get a chunk.
var chunk = http.read_response_body_chunk()
if chunk.size() == 0:
if not OS.has_feature("web"):
# Got nothing, wait for buffers to fill a bit.
OS.delay_usec(1000)
else:
yield(Engine.get_main_loop(), "idle_frame")
await get_tree().process_frame
else:
rb = rb + chunk # Append to read buffer.
# Done!
Expand Down