Skip to content

llGetHTTPHeader

string llGetHTTPHeader(key HTTPRequestID, string Header)

Returns the value for header for request_id.

Returns a string that is the value of the Header for HTTPRequestID.

Parameters
HTTPRequestID (key)
A valid HTTP request key
Header (string)
Header value name

These headers are automatically generated by the simulator and were not sent by the requesting client. They provide information about the request to make parsing easier:

HeaderDescriptionExample
x-script-urlThe base URL as received from llRequestURL/llRequestSecureURLhttps://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322
x-path-infoAny trailing path information from the requested URL/foo/bar
x-query-stringAny query arguments (text after ? in the URL)arg=gra
x-remote-ipIP address of the host that made the request
HeaderDescriptionExample
user-agentThe user-agent header as reported by the requester
key url_request;
default
{
state_entry()
{
url_request = llRequestURL();
}
http_request(key id, string method, string body)
{
if (url_request == id)
{
// Reset the query ID
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);
llOwnerSay("body:\n" + body);
llHTTPResponse(id, 200, body);
}
}
}
  • Header information becomes inaccessible after 30 seconds or if llHTTPResponse is called
  • Function returns an empty string in any context outside the http_request event; it cannot be used in the http_response event
  • Custom headers are not supported; only headers listed in the specification are supported
  • 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”
  • Header must be lowercase (or it will match nothing); all header names are converted to lowercase when received
  • When making a request with llHTTPRequest:
    • The path part of the URL must be prefixed with a forward slash
      • Good: https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322/foo
      • Bad: https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322foo
    • To use the query string, you must include a path (even if it is just a slash)
      • Good: https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322/?arg=gra
      • Bad: https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322?arg=gra