Jump to content
Innula Zenovka

Advice on http error codes, please

Recommended Posts

I need to do some error handling and I'm not sure how best to proceed.   When a script throws the occasional error message "URL passed to llHTTPRequest is not valid," what error code should I be looking for in the http_response event, or don't we get that far?    

As far as I can tell from my debug logs, the script is always passing valid URLs (or, rather, URLs that have been valid in the recent past).

I really, really don't want to use if(status != 200) if I can avoid it.    I'd rather be more specific.

 

Share this post


Link to post
Share on other sites

i haven't played with http for ages but as I remember the status parameter is consistent with HTTP/1.1 RFC 2616

https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html

how reliably LSL follows this I dunno as when I did play with it then I went with if(status != 200) :)

  • Thanks 1

Share this post


Link to post
Share on other sites
21 hours ago, Innula Zenovka said:

I need to do some error handling and I'm not sure how best to proceed.   When a script throws the occasional error message "URL passed to llHTTPRequest is not valid," what error code should I be looking for in the http_response event, or don't we get that far?    

No request is sent for that error, and no response is generated.

It is true that some url parameters that were actually invalid used to be accepted and are now rejected by stricter tests.  Feel free to post examples.

  • Thanks 3

Share this post


Link to post
Share on other sites

Thanks, Oz.    It's a vendor, which sends customers' UUIDs to a remote server, which sends an object to the avatar whose UUID it receives.   The only parameter I'm using is [HTTP_METHOD,"POST"], and I'm reading urls from a KVP key written by the remote servers (there are back-up ones on different regions.   

llHTTPRequest(strURL, [HTTP_METHOD,"POST"],llList2String(lRequestsToBeProcessed, 0)) ;

The string is the customer's UUID and an integer between 0 and 5 (to identify the item requested), separated by a tilde.    The url is in the format  http://sim10038.agni.lindenlab.com:12046/cap/4fefe082-f51c-f4ab-225e-fe7befb8f096 (that's not necessarily the one that caused the error,  but it's one used about the time of the error, and all the urls used around that time were similar).

Most of the time things works as expected, but occasionally I get the error I described, which puzzles me.

I want to be able to handle the error, but if no request is sent for that particular error, then how do I detect it?   Start a timer and, if I don't receive a timely response from the server, then assume something is wrong? 

  • Like 1

Share this post


Link to post
Share on other sites
16 minutes ago, Innula Zenovka said:

I want to be able to handle the error, but if no request is sent for that particular error, then how do I detect it?

llHTTPRequest will return a null key whenever there is any error that does not send a request, so you could do something like

 
key request_id = llHTTPRequest(strURL, [HTTP_METHOD,"POST"],llList2String(lRequestsToBeProcessed, 0)) ;
if (request_id == NULL_KEY)
{
   llOwnerSay("invalid url " + strURL);
}

 

  • Thanks 4

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...