Blockland Forums > Modification Help
TorqueScript HTTP Request
<< < (2/2)
Human Reaper:
Ok, well its funny to me. Must be thinking of a diffrent thing.
Bauklotz:
If you just want a basic request:

new httpObject(example);
function example::onLine(%this, %line) {
    cancel(%this.finished);
    %this.page = %this.page @ %line NL "";
    %this.finished = %this.schedule(250, finished);
}
function example::finished(%this) {
    %this.disconnect();
    echo(%this.page);
}

...

example.get("blockland.us:80", "/");


Added the 'finished' thing for websites that don't feel like disconnecting you.

If you want something more advanced, header control, working multiple-PHP-arguments, etc, use TCPObjects.
Ephialtes:

--- Quote from: Bauklotz on March 07, 2011, 05:58:27 AM ---Added the 'finished' thing for websites that don't feel like disconnecting you.

--- End quote ---

That's a pretty bad idea. You should be sending a "Connection: close" header to make sure the server knows to close the connection once output is done.
Bauklotz:

--- Quote from: Bauklotz on March 07, 2011, 05:58:27 AM ---If you want something more advanced, header control, working multiple-PHP-arguments, etc, use TCPObjects.

--- End quote ---
Ephialtes:
I'd say wanting to be sure a connection terminates after data's been received would fall under "advanced" instead of just hacking it up like that. That hack won't even ensure you get all the data from a page. I wouldn't recommend using it.
Navigation
Message Index
Previous page

Go to full version