Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

String won't parse?

Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
03-24-2007 14:10
I've got a script in which I send an HTTPRequest to a webpage, and the webpage responds....

...the response-handling is detailed below

CODE


http_response(key id, integer status, list meta, string body)
{
llWhisper(0, "RECEIVING HTTP: " + body);
if (id == reqid)
{
llWhisper(0, "HTTP MATCHES WEBSITE");
string ls = llGetSubString(body, 0, 4);
string lsid = llGetSubString(body, 5, -1);
string qls = "CHECK";
llWhisper(0, "CHECKING IF: " + ls + " IS EQUAL TO: " + qls + " IF SO, ID = " + lsid);
if(ls == qls)
{
llWhisper(0, "MATCH FOUND");
}
else if(body != "") llWhisper(0, body);
}
}
return;
}


The response I get:

"RECEIVING HTTP: CHECK7"
"RECEIVING HTTP:"
"RECEIVING HTTP:"

"HTTP MATCHES WEBSITE"

"CHECKING IF: IS EQUAL TO: CHECK IF SO, ID = "


I'm a bit confuseded?
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Dragon Keen
Registered User
Join date: 24 Apr 2006
Posts: 245
03-24-2007 16:09
its something else entirely... if your getting 3 of these

"RECEIVING HTTP: CHECK7"
"RECEIVING HTTP:"
"RECEIVING HTTP:"

before the id=reqid, there are 3 returns to the httprequest
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
03-24-2007 19:14
*nods*

I eventually discovered that such was the issue...

...it seems that the LSL Script is slow enough in processing returns, that it takes all three at once (all three are individual requests doing different things) and returns them to the HTTP_Response event, checking only the FINAL reqid...the actual time between one request and another was about 1 second...at that point, the reqid had changed (due to the next request) and so the first return skipped out.

...even placing a delay in the script failed to overcome the problem, as the script does not process at all when in an llSleep(). I had to work around it and put the other two requests in a completely separate function.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
I Hope you're wrong!!!!
03-25-2007 00:09
From: Kenn Nilsson
*nods*

I eventually discovered that such was the issue...

...it seems that the LSL Script is slow enough in processing returns, that it takes all three at once (all three are individual requests doing different things) and returns them to the HTTP_Response event, checking only the FINAL reqid...the actual time between one request and another was about 1 second...at that point, the reqid had changed (due to the next request) and so the first return skipped out.

...even placing a delay in the script failed to overcome the problem, as the script does not process at all when in an llSleep(). I had to work around it and put the other two requests in a completely separate function.


I really really hope you're wrong about that statement.
LSL is meant to be blocking in operation, i.e. once an event handler has started processing no other event handlers INCLUDING itself can run again until it completes.
If what you say is happening then there has been a fundemental change to that which breaks an awful lot of code
Peekay Semyorka
Registered User
Join date: 18 Nov 2006
Posts: 337
03-25-2007 08:46
I don't see any evidence here that the event handlers are suddenly reentrant.

What's likely happening is the script is making three requests before a response comes in, but incorrectly keeps track of only the last request's id. Either serialize the requests/responses (i.e., don't send another request until a response comes back), or keep track of all pending request ids (say, in a list).

-peekay
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-25-2007 11:46
From: Peekay Semyorka
I don't see any evidence here that the event handlers are suddenly reentrant.

What's likely happening is the script is making three requests before a response comes in, but incorrectly keeps track of only the last request's id. Either serialize the requests/responses (i.e., don't send another request until a response comes back), or keep track of all pending request ids (say, in a list).

-peekay

Yep you're right, the first say is outside of the id check. I didnt notice when i first read the post.