Skip to content

Instantly share code, notes, and snippets.

@mhilbrunner
Created June 3, 2018 22:52
Show Gist options
  • Save mhilbrunner/fcfba1f1c4927d29c5dd6c318f0d7817 to your computer and use it in GitHub Desktop.
Save mhilbrunner/fcfba1f1c4927d29c5dd6c318f0d7817 to your computer and use it in GitHub Desktop.
extends Node2D
func _ready():
$Button/request.connect("request_completed", self, "_request_completed")
func _on_Button_pressed():
var fields = {"username" : "user", "password" : "pass"}
var queryString = HTTPClient.new().query_string_from_dict(fields)
print(queryString)
var headers = ["Content-Type: application/x-www-form-urlencoded", "Content-Length: " + str(queryString.length())]
$Button/request.request("https://postman-echo.com/get", headers, false, HTTPClient.METHOD_GET, queryString)
func _request_completed(result, response_code, headers, body):
print("Request completed", result, response_code, headers, body.get_string_from_utf8())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment