Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Tech Support (https://forums.graalonline.com/forums/forumdisplay.php?f=7)
-   -   HTTP Requests and hosts (https://forums.graalonline.com/forums/showthread.php?t=63088)

Riot 12-30-2005 02:47 PM

HTTP Requests and hosts
 
I noticed several revisions ago that some new request commands were added on the client-end, one of which involves HTTP requests. This is great, but it does not seem to be sending the Host to the server, which can cause problems with some web hosts.

The code I'm using:
HTML Code:

//#CLIENTSIDE
function onCreated()
{
  this.request = requesthttp("delteria.com", 80, "/test.txt");
  setTimer(0.1);
}

function onTimeout()
{
  // Check if the file has finished downloading
  if (this.request.downloadcomplete)
  {
    // The file has finished downloading, output data to console
    for (data: this.request.data)
      echo(data);
  }
  else
  {
    // File hasn't finished downloading yet, wait another 0.1 seconds
    // and check again.
    setTimer(0.1);
  }
}

This returns a 404 error, and if I change /test.txt to /index.html, it returns cPanel's "no website configured" page (Which can be seen here.) rather than http://delteria.com/test.txt. I can work around it by doing requesthttp("delteria.com", 80, "/~delteria/test.txt"); but it would still be nice if this was looked into.

I was also wondering if/when this will be supported serverside; and I noticed a "requestmysql" command as well, but have no clue how to use it. I tried to assume params and output variables/functions, but only got the defaults.

Admins 12-30-2005 03:56 PM

This is the preferred way of using the new functionality:

PHP Code:

function onCreated() {
  
this.req requestURL("http://www.graalonline.com/about/whatis.php");
  
catchevent(this.req,"onReceiveData","onData");
}

function 
onData(obj) {
  echo(
"got data: " obj.name " - " obj.returncode @
    
" - " obj.returnmessage " - " obj.server " - " obj.contenttype);
  echo(
"data: " obj.data.size());
  
this.req NULL;


It is working on serverside, but you must use ips instead of urls (194.5.30.4 instead of www.graalonline.com) otherwise it is crashing because of libc compatibility problems, will fix that soon.
It is currently only using HTTP 1.0, will try to check your problem soon.

Maniaman 12-31-2005 07:31 PM

The command I have been waiting for has finally been added. Awesome :)


All times are GMT +2. The time now is 04:37 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.