Author Topic: Connecting to MySQL.  (Read 1210 times)

Tom

This code:
Code: [Select]
new TCPObject(TCPObj)
{
   site = "tomtest.kbyet.com";
   port = 80;
};

function tcp()
{
TCPObj.connect("tomtest.kbyet.com:80");
}

function TCPObj::onConnected(%this)
{
echo("CONNECTED");
$file="/test.php";
$url="tomtest.kbyet.com:80";
%this.send("GET "@$file@" HTTP/1.0\nHost: " @$url@"\nUser-Agent: Torque\n\r\n\r\n");
}

function TCPObj::onLine(%this,%line)
{
echo(%line);
}
Did I mess up the User agent, because it sends me HTML for some webpage about PHP.
Wait I might of fixed it :P
EDIT: YES I GOT IT!

But it sends me this:
Code: [Select]
CONNECTED
HTTP/1.1 200 OK
Date: Fri, 12 Jun 2009 16:00:49 GMT
Server: Apache
Cache-Control: no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform
Expires: Fri, 12 Jun 2009 16:00:49 GMT
Vary: Accept-Encoding,User-Agent
Pragma: no-cache
Content-Type: text/html
X-Cache: MISS from demil1.byetcluster.com
X-Cache-Lookup: MISS from demil1.byetcluster.com:80
Via: 1.1 demil1.byetcluster.com:80 (Lusca/LUSCA_1.0)
before teh contetns of the file.
Anyway to remove it without removing the lines with Troque?
« Last Edit: June 12, 2009, 12:03:55 PM by Tom »

You always get HTTP Headers returned by a webserver. You can throw this in the onLine:

Code: [Select]
if(!%this.doneHeaders)
{
    if(%line $= "")
        %this.doneHeaders = 1;
    return;
}
echo(%line);