Work in progress
The content of this page was not yet updated for Godot
and may be outdated. If you know how to improve this page or you can confirm
that it's up to date, feel free to open a pull request.
HTTP client class¶
When exporting to Android, make sure to enable the
permission in the Android export preset before exporting the project or
using one-click deploy. Otherwise, network communication of any kind will be
blocked by Android.
Here's an example of using the HTTPClient class. It's just a script, so it can be run by executing:
c:\godot> godot -s http_test.gd
c:\godot> godot -s HTTPTest.cs
It will connect and fetch a website.
extends SceneTree # HTTPClient demo # This simple class can do HTTP requests; it will not block, but it needs to be polled. func _init(): var err = 0 var http = HTTPClient.new() # Create the Client. err = http.connect_to_host("www.php.net", 80) # Connect to host/port. assert(err == OK) # Make sure connection is OK. # Wait until resolved and connected. while http.get_status() == HTTPClient.STATUS_CONNECTING or http.get_status() == HTTPClient.STATUS_RESOLVING: http.poll() print("Connecting...") if not OS.has_feature