Author Topic: Http Objects crash on page load - Alternatives?  (Read 552 times)

I'm using an http object to download the contents from a search page.
However, the game crashes upon trying to load the page. I've heard that I could use a TCP object to download the page, but I haven't figured out how to do the GET request correctly, I keep getting bad request errors.

I've put in echos previously, the game crashes as soon as it starts receiving data through the httpObject.
« Last Edit: November 23, 2013, 02:03:15 PM by Pecon »

HTTPObjects don't support URL arguments, you have to use TCPObjects.

Given the server (ie www.random.org) and the URL arguments (ie. /gimmenumbers.php?stuff=goes_here) and the following code:
Code: [Select]
function webSearchClass::onConnected(%this)
{
%this.send("GET" SPC %this.urlreq SPC "HTTP/1.0\nHost:" SPC %this.server @ "\r\n\r\n");
}

function webSearchClass::onDisconnect(%this)
{
%this.schedule(0, delete);
}

function webSearchClass::onLine(%this,%line)
{
//Do things
}

function webSearchClass::sendRequest(%this)
{
%this.connect(%this.server @ ":80");
}

You can do the following:

Code: [Select]
$PageGetter = new TCPObject(webSearchClass)
{
server = "api.duckduckgo.com";
urlreq = //stuff goes here;
};

$PageGetter.sendRequest();