LlGetHTTPHeader

From Second Life Wiki

Jump to: navigation, search

Template:Needs Translation/LSL/de Template:Needs Translation/LSL/es Template:Needs Translation/LSL/el Template:Needs Translation/LSL/fr Template:Needs Translation/LSL/he Template:Needs Translation/LSL/it Template:Needs Translation/LSL/ja 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

Summary

Function: string llGetHTTPHeader( key request_id, string header );
349 Function ID
0.0 Delay
10.0 Energy

Returns a string that is the value for header for request_id.

• key request_id A valid HTTP request key.
• string header Header value name.

Specification

Generated Headers

These headers are automatically generated by the simulator, they were not actually sent by the requesting client. They supply information about the request to make parsing easier.

Sample URL: https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322/foo/bar?arg=gra

header description example
"x-script-url" The base url, as originally received from llRequestURL/llRequestSecureURL https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322
"x-path-info" Any trailing path information from the requested url /foo/bar
"x-query-string" Any query arguments, the text past the first "?" in the url arg=gra
"x-remote-ip" IP address of the host that made the request

Common Headers

header description example
"user-agent" The user-agent header as reported by the requester

llHTTPRequest 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".

Caveats

  • LSL is not a CGI environment
    • "Content-Type" is an example of a normal header name, in a CGI environment the name would be "HTTP_CONTENT_TYPE".
  • This header information is valid for 30 seconds, or until llHTTPResponse is called.
  • The header names listed above are incorrect - they should all be fully lower case (i.e. x-secondlife-shard, x-secondlife-object-name, x-secondlife-object-key, x-secondlife-region, etc.

Search JIRA for related Bugs

Examples

 
key url_request;
 
default
{
    state_entry()
    {
        url_request = llRequestURL();
    }
    http_request(key id, string method, string body)
    {
        if (url_request == id)
        {
            url_request = "";
            if (method == URL_REQUEST_GRANTED)
            {
                llOwnerSay("URL: " + body);
                if(llGetAgentSize(llGetOwner()))
                    llLoadURL(llGetOwner(), "", body);
            }
            else if (method == URL_REQUEST_DENIED)
            {
                llOwnerSay( "Something went wrong, no url. " + body);
            }
        }
        else
        {
            list headers = [ "x-script-url", "x-path-info", "x-query-string", "x-remote-ip", "user-agent" ];
            integer pos = ~llGetListLength(headers);
            while( ++pos )
            {
                string header = llList2String(headers, pos);
                llOwnerSay(header + ": " + llGetHTTPHeader(id, header));
            }
            llOwnerSay( "body: " + body);
            llHTTPResponse(id, 200, body);
        }
    }
}
 

See Also

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