Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llHTTPRequest makes my object say "200 error"

Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
10-18-2007 15:11
Hi there,

I'm trying to get my feet wet with LSL and PHP and something really strange happens: My object says "200 error" on chat channel 0 altho it only uses llOwnerSay().

I googled the web and the forums to find an explanation but I found nothing.

Here is my little LSL script:
-------------------------------
string host = "http://my.host.com/myfile.php";
key req_id;

default
{
touch_start(integer total_number)
{
string query = "?name=" + llEscapeURL(llDetectedName(0))
+ "&key=" + (string)llDetectedKey(0);
req_id = llHTTPRequest(host + query, [], "";);
}

http_response(key request_id, integer status, list metadata, string body)
{
if (req_id == request_id)
{
llOwnerSay("Status: " + (string)status);
integer i = llSubStringIndex(body, "<DATA>";);
integer j = llSubStringIndex(body, "</DATA>";);
// Delimiters because the free webhost adds unwanted stuff
if ( (i != -1) & (j != -1) )
{
body = llGetSubString(body, i + 6, j - 1);
llOwnerSay(body);
}
else
{
llOwnerSay("*** ERROR ***";);
llOwnerSay(body);
}
}
}
}
-------------------------------
All it does is to send the key and the name of the AV touching the object to the server which sends them back.

And here is the tiny PHP script:
-------------------------------
<?php
$name = urldecode($_GET['name']);
$key = $_GET['key'];
$return = "<DATA>Key: ".$key." | Name: ".$name." touched me.</DATA>\n";
echo $return;
?>
-------------------------------

Result:
-------------------------------
(Plain chat)
[14:48] Object: 200 error
(Owner only)
[14:48] Object: Status: 200
[14:48] Object: Key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx | Name: Kaluura Boa touched me.
-------------------------------

Where does this extraneous chat line comes from? Is there a way to prevent it? Who's fault is it?

Any hint/idea/suggestion?
Jana Kamachi
Registered User
Join date: 19 Apr 2007
Posts: 111
10-18-2007 19:07
lookup the HTTP 1.0 error code specifications. Then look under 200.
Masakazu Kojima
ケロ
Join date: 23 Apr 2004
Posts: 232
10-18-2007 19:19
200 is success. There is probably another script in the object.

I'd guess it looks like:

if ( req_id == request_id && status == 200 ) {
// ...
} else {
llSay(0, (string)status + " error";);
}
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
Errrr...
10-19-2007 05:18
From: Masakazu Kojima
200 is success. There is probably another script in the object.


LOL Yes, there is another script... Stupid me and stupid script! Problem solved.

Thanks for the enlightenment.