Http response

From Second Life Wiki

Second Life Wiki > LSL Portal > Events > Http response
Jump to: navigation, search

Template:Needs Translation/LSL/de Template:Needs Translation/LSL/es Template:Needs Translation/LSL/el Template:Needs Translation/LSL/he Template:Needs Translation/LSL/it Template:Needs Translation/LSL/ko Template:Needs Translation/LSL/nl Template:Needs Translation/LSL/hu Template:Needs Translation/LSL/no Template:Needs Translation/LSL/da Template:Needs Translation/LSL/sv Template:Needs Translation/LSL/tr Template:Needs Translation/LSL/pl Template:Needs Translation/LSL/pt Template:Needs Translation/LSL/ru Template:Needs Translation/LSL/uk Template:Needs Translation/LSL/zh-Hans Template:Needs Translation/LSL/zh-Hant

Contents

Description

Event: http_response( key request_id, integer status, list metadata, string body ){ ; }

Triggered when task receives a response to one of its llHTTPRequests

• key request_id Matches return from llHTTPRequest
• integer status HTTP code (like 404 or 200)
• list metadata List of HTTP_* constants and attributes
• string body

Specification

Status 415 "Unsupported or unknown Content-Type"

The remote server did reply to your request but the Content-Type of the reply (such as XML, JSON, Atom, RSS, PLS) is not recognised by the LL server and so is not passed back to the script. You can assume that 415 means the server heard your request and did reply.

Status 499

Besides the usual HTTP status codes, SL implements a special status code 499. This code isn't generated by the remote web server but by SL's servers, it can indicate:

  • Request timeout (60 seconds)
  • SSL failure
  • A space was present in the url (escape your URL with llEscapeURL).
Constant Type Description
HTTP_BODY_TRUNCATED 0 integer Truncation point in bytes

Examples

key http_request_id;
 
default
{
    state_entry()
    {
        http_request_id = llHTTPRequest("url", [], "");
    }
 
    http_response(key request_id, integer status, list metadata, string body)
    {
        if (request_id == http_request_id)
        {
            llSetText(body, <0,0,1>, 1);
        }
    }
}

Notes

Parsing Problems

If for some reason while using llHTTPRequest/http_response you are unable to parse a known good RSS feed or some other form of web contents, you will need to work around it outside of SecondLife. This is unlikely to change in the near future since checking the headers requires more overhead at the simulator level.

Unicode

When serving content with UTF-8 characters be sure your server sets the outgoing "Content-Type" header so that it includes "charset=utf-8" otherwise it will be interpreted incorrectly. See W3C:Setting the HTTP charset parameter for further details.

Request Headers

Headers sent by the simulator in the course of calling llHTTPRequest.
Header Description Example data
X-SecondLife-Shard The environment the object is in. "Production" is the main grid and "Testing" is the preview grid Production
X-SecondLife-Object-Name The name of the object containing the script Object
X-SecondLife-Object-Key The key of the object containing the script 01234567-89ab-cdef-0123-456789abcdef
X-SecondLife-Region The name of the region the object is in, along with the global coordinates of the region's south-west corner Jin Ho (264448, 233984)
X-SecondLife-Local-Position The position of the object within the region (173.009827, 75.551231, 60.950001)
X-SecondLife-Local-Rotation The rotation of the object containing the script 0.000000, 0.000000, 0.000000, 1.000000
X-SecondLife-Local-Velocity The velocity of the object 0.000000, 0.000000, 0.000000
X-SecondLife-Owner-Name Name of the owner of the object Zeb Wyler
X-SecondLife-Owner-Key UUID of the owner of the object 01234567-89ab-cdef-0123-456789abcdef
CGI environments may place the headers into variables by capitalizing the entire name, replacing dashes with underscores, and prefixing the name with "HTTP_", e.g. "X-SecondLife-Object-Name" becomes "HTTP_X_SECONDLIFE_OBJECT_NAME".

See Also

Functions

•  llHTTPRequest
This article wasn't helpful for you? Maybe the related article at the LSL Wiki is able to bring enlightenment.
Personal tools
In other languages