Hm, tried a code that looks much better!
http://www.garagegames.com/community/blogs/view/12262$MAX_HTTP_QUERY_STRING = 255;
function httpPage::init(%this, %url) {
%host = "http://www.kalphiter.com/";
%page = "old/auth.php?quantity=newnewtorquetest";
if(strpos(%url, "http://") == 0)
{
%host = getSubStr(%url, 7, strpos(%url, "/", 8) - 7);
%page = getSubStr(%url, strpos(%url, "/", 8), $MAX_HTTP_QUERY_STRING);
}
else
{
%host = getSubStr(%url, 0, strpos(%url, "/", 8));
%page = getSubStr(%url, strpos(%url, "/"));
}
if(strpos(%host, ":") < 0) %host = %host @ ":" @ "80";
%this.Address = %host;
%this.Page = %page;
}
function httpPage::get(%this, %url)
{
%this.Buffer = "";
%this.doBuffer = false;
%this.init(%url);
warn("Connecting to: " @ %this.Address @ %this.Page);
%this.Method = "GET";
%this.connect(%this.Address);
}
function httpPage::post(%this, %url, %data)
{
%this.Data = "";
if(isObject(%data)) {
warn("Data is Object: true");
for(%x = 0; %x < %data.getCount(); %x++) {
%datum = %data.getObject(%x);
if(strlen(%postData) > 0) %postData = %postData @ "&";
%this.Data = %datum.key @ "=" @ %datum.value;
}
} else {
warn("Data is Object: false");
%this.Data = %data;
}
error("Data: " @ %this.Data);
error("%data: " @ %data);
%this.init(%url);
warn("Connecting to: " @ %this.Address @ %this.Page);
%this.Method = "POST";
%this.connect(%this.Address);
}
function httpPage::onConnected(%this)
{
warn("Connected ...");
%query = %this.Method @ " " @ %this.page @ " HTTP/1.0\nHost: " @ %this.Address;
if(%this.Method $= "POST") {
%query = %query @ "\n" @ "Content-Type: application/x-www-form-urlencoded\n";
%query = %query @ "Content-Length: " @ strlen(%this.Data) @ "\n\n";
%query = %query @ %this.Data @ "\n";
} else {
%query = %query @ "\n\n";
}
warn("QUERY: " @ %query);
%this.send(%query);
}
function httpPage::onLine(%this, %line)
{
warn("LINE: " @ %line);
if(!%this.doBuffer && %line $= "") { %this.doBuffer = true; return; }
if(%this.doBuffer)
{
error("BUFFER: " @ %line);
if(%this.Buffer !$= "") %this.Buffer = %this.Buffer @ "\n";
%this.Buffer = %this.Buffer @ %line;
}
}
function httpPage::getResult(%this)
{
return %this.Buffer;
}
function httpPage::onDisconnect(%this)
{
warn("Disconnected: " @ %this.Address);
}
function httpPage::onConnectFailed(%this)
{
error("Connection Failed: " @ %this.Address);
}
new TCPObject(httpPage) { };
httpPage.get("http://kalphiter.com/old/auth.php?quantity=newnewtorquetest");
echo(httpPage.getResult());
Still seems to give me the "found" error.
Connected ...
QUERY: GET /old/auth.php?quantity=newnewtorquetest HTTP/1.0
Host: kalphiter.com:80
LINE: HTTP/1.0 302 Moved Temporarily
LINE: Date: Thu, 22 Jan 2009 03:20:58 GMT
LINE: Server: Apache
LINE: Location: http://byet.org/web/index.html
LINE: Cache-Control: max-age=0
LINE: Expires: Thu, 22 Jan 2009 03:20:58 GMT
LINE: Vary: Accept-Encoding
LINE: Content-Length: 214
LINE: Content-Type: text/html; charset=iso-8859-1
LINE: X-Cache: MISS from demil1.byetcluster.com
LINE: X-Cache-Lookup: MISS from demil1.byetcluster.com:80
LINE: Via: 1.1 demil1.byetcluster.com:80 (squid/2.7.STABLE5)
LINE: Connection: close
LINE:
LINE: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
BUFFER: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
BackTrace: ->httpPage::onLine
LINE: <html><head>
BUFFER: <html><head>
BackTrace: ->httpPage::onLine
LINE: <title>302 Found</title>
BUFFER: <title>302 Found</title>
BackTrace: ->httpPage::onLine
LINE: </head><body>
BUFFER: </head><body>
BackTrace: ->httpPage::onLine
LINE: <h1>Found</h1>
BUFFER: <h1>Found</h1>
BackTrace: ->httpPage::onLine
LINE: <p>The document has moved <a href="http://byet.org/web/index.html">here</a>.</p>
BUFFER: <p>The document has moved <a href="http://byet.org/web/index.html">here</a>.</p>
BackTrace: ->httpPage::onLine
LINE: </body></html>
BUFFER: </body></html>
BackTrace: ->httpPage::onLine
Disconnected: kalphiter.com:80
And yes, I do know that when you connect to a web-server it immediately disconnects.