Hi guys,
I’m working on the next version of Roo, my drop-in replacement for Xojoscript and I’m adding basic support for networking. Specifically I want to add support for HTTP GET and POST requests as the other app I’m working on which uses Roo as its scripting language needs that support.
Ultimately I want to be able to do this with Roo:
var request = Request();
request.headers = {"Accept" => "text/plain", "Connection" => "keep-alive"};
request.method = HTTP.GET;
request.url = "https://example.com";
var response = request.send; # Make the request.
print(response.content); # Prints the content of the response.
I will be backing Roo’s networking class with the Xojo.Net.HTTPSocket
class. I know that this did away with synchronous requests but I’m hoping someone can help me figure out a way to hack together a synchronous call with it. Perhaps with a Timer
? I know asynchronous requests are best but like I said, Roo is an imperative language (NOT event driven) and therefore I don’t want the code after the network call to execute until the network request is finished.
Does anyone have any ideas? I don’t want to use the legacy HTTPSocket
class as I want to provide HTTP 1.1 support.