Godot 3.0 Http

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ComanderKai77
:warning: Old Version Published before Godot 3 was released.

Will there be a method (or is) to download a string via https from a server with only a few lines of code like in C# with WebClient.DownloadString and not with 30 lines or so like here
Godot HTTP client class?

:bust_in_silhouette: Reply From: Elinvention

Yes, I had the same problem, then I found this.
Add an HTTPRequest node in the editor called http. Then you can simply:

$"http".request(url)

To get the result of the request you can use connect to register a method that will be called when the request is completed:

$"http".connect("request_completed", self, "_on_request_completed")

The method will look like this:

func _on_request_completed(result, response_code, headers, body):
	$"http".disconnect("request_completed", self, "_on_request_completed")
	if result == HTTPRequest.RESULT_SUCCESS and response_code == 200:
		var parsed_json = str2var(body.get_string_from_utf8())
	else:
		printerr("Request error")