Skip to content
lsl.devlsl.devLSL Dev

llGetHTTPHeader

function
Function syntax
string llGetHTTPHeader(
  1. key request_id,// Unique key of the HTTP request.
  2. string header// Lowercase name of the HTTP header to retrieve.
);
Returns
string
Energy
10

Returns an empty string if the header is not found, if the request_id is not a valid key received through the http_request event, or if the headers can no longer be accessed. Headers can only be accessed before llHTTPResponse is called and with-in the first 30 seconds after the http_request event is queued.

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

How to use
string result = llGetHTTPHeader(NULL_KEY, "");

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

headerdescriptionexample
“x-script-url”The base url, as originally received from llRequestURL/llRequestSecureURLhttps://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 urlarg=gra
“x-remote-ip”IP address of the host that made the request
headerdescriptionexample
“user-agent”The user-agent header as reported by the requester
Headers sent by the simulator in the course of calling llHTTPRequest.
HeaderDescriptionExample data
connectionConnection optionsclose
cache-controlMaximum response age accepted.max-age=259200
x-forwarded-forUsed to show the IP address connected to through proxies.127.0.0.1
viaShows the recipients and protocols used between the User Agent and the server.1.1 sim10115.agni.lindenlab.com:3128 (squid/2.7.STABLE9)
content-lengthThe size of the entity-body, in decimal number of octets.17
pragmaThe message should be forwarded to the server, even if it has a cached version of the data.no-cache
x-secondlife-shardThe environment the object is in. “Production” is the main grid and “Testing” is the preview gridProduction
x-secondlife-regionThe name of the region the object is in, along with the global coordinates of the region’s south-west cornerJin Ho (264448, 233984)
x-secondlife-owner-nameLegacy name of the owner of the objectZeb Wyler
x-secondlife-owner-keyUUID of the owner of the object01234567-89ab-cdef-0123-456789abcdef
x-secondlife-object-nameThe name of the object containing the scriptObject
x-secondlife-object-keyThe key of the object containing the script01234567-89ab-cdef-0123-456789abcdef
x-secondlife-local-velocityThe velocity of the object0.000000, 0.000000, 0.000000
x-secondlife-local-rotationThe rotation of the object containing the script0.000000, 0.000000, 0.000000, 1.000000
x-secondlife-local-positionThe position of the object within the region(173.009827, 75.551231, 60.950001)
user-agentThe user-agent header sent by LSL Scripts. Contains Server version.Second Life LSL/16.05.24.315768 (http://secondlife.com)
content-typeThe media type of the entity body.text/plain; charset=utf-8
accept-charsetAcceptable character sets from the server. Q being the quality expected when sending the different character sets.utf-8;q=1.0, *;q=0.5
acceptMedia types the server will accept.text/*, application/xhtml+xml, application/atom+xml, application/json, application/xml, application/llsd+xml, application/x-javascript, application/javascript, application/x-www-form-urlencoded, application/rss+xml
accept-encodingAcceptable content encodings for the server.deflate, gzip
hostThe internet host being requested.secondlife.com
Example 1
40 collapsed lines
key url_request;
default
{
state_entry()
{
url_request = llRequestURL();
}
http_request(key id, string method, string body)
{
if (url_request == id)
{
// if you're usually not resetting the query ID
// now is a good time to start!
url_request = "";
if (method == URL_REQUEST_GRANTED)
{
llOwnerSay("URL: " + body);
key owner = llGetOwner();
vector ownerSize = llGetAgentSize(owner);
if (ownerSize)// != ZERO_VECTOR
llLoadURL(owner, "I got a new URL!", body);
}
else if (method == URL_REQUEST_DENIED)
llOwnerSay("Something went wrong, no url:\n" + body);
}
else
{
list headerList = ["x-script-url",
"x-path-info", "x-query-string",
"x-remote-ip", "user-agent"];
integer index = -llGetListLength(headerList);
do
{
string header = llList2String(headerList, index);
llOwnerSay(header + ": " + llGetHTTPHeader(id, header));
}
while (++index);
6 collapsed lines
llOwnerSay("body:\n" + body);
llHTTPResponse(id, 200, body);
}
}
}
  • SVN:1836 r112899 Trunk
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.