Graal Forums  

Go Back   Graal Forums > Development Forums > Tech Support
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-30-2005, 02:47 PM
Riot Riot is offline
Delteria Management
Join Date: Nov 2003
Location: Seminole County, Florida
Posts: 280
Riot is on a distinguished road
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.
Reply With Quote
  #2  
Old 12-30-2005, 03:56 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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.
Reply With Quote
  #3  
Old 12-31-2005, 07:31 PM
Maniaman Maniaman is offline
Registered User
Join Date: Aug 2005
Posts: 326
Maniaman is on a distinguished road
The command I have been waiting for has finally been added. Awesome
__________________

Current Maloria Event: (click to go to it)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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