# llGetHTTPHeader

*LSL function*

```lsl
string string llGetHTTPHeader(key request_id, string header);
```

- `key request_id`: Unique key of the HTTP request.
- `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](/events/http_request/) event, or if the headers can no longer be accessed. Headers can only be accessed before [llHTTPResponse](/functions/llHTTPResponse/) is called and with-in the first 30 seconds after the [http_request](/events/http_request/) event is queued.

Returns a [string](https://wiki.secondlife.com/wiki/string) that is the value for **header** for **request_id**.

```lsl title="How to use" frame="terminal"
string result = llGetHTTPHeader(NULL_KEY, "");
```

## 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](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](/functions/llRequestURL/)/[llRequestSecureURL](/functions/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](/functions/llHTTPRequest/) Headers

<table>
	<caption>Headers sent by the simulator in the course of calling [llHTTPRequest](/functions/llHTTPRequest/).</caption>
	<tr>
		<th>Header</th>
		<th>Description</th>
		<th>Example data</th>
	</tr>
	<tr>
		<td>connection</td>
		<td>Connection options</td>
		<td>close</td>
	</tr>
	<tr>
		<td>cache-control</td>
		<td>Maximum response age accepted.</td>
		<td>max-age=259200</td>
	</tr>
	<tr>
		<td>x-forwarded-for</td>
		<td>Used to show the IP address connected to through proxies.</td>
		<td>127.0.0.1</td>
	</tr>
	<tr>
		<td>via</td>
		<td>Shows the recipients and protocols used between the User Agent and the server.</td>
		<td>1.1 sim10115.agni.lindenlab.com:3128 (squid/2.7.STABLE9)</td>
	</tr>
	<tr>
		<td>content-length</td>
		<td>The size of the entity-body, in decimal number of octets.</td>
		<td>17</td>
	</tr>
	<tr>
		<td>pragma</td>
		<td>The message should be forwarded to the server, even if it has a cached version of the data.</td>
		<td>no-cache</td>
	</tr>
	<tr>
		<td>x-secondlife-shard</td>
		<td>The environment the object is in. "Production" is the main grid and "Testing" is the preview grid</td>
		<td>Production</td>
	</tr>
	<tr>
		<td>x-secondlife-region</td>
		<td>The name of the region the object is in, along with the global coordinates of the region's south-west corner</td>
		<td>Jin Ho (264448, 233984)</td>
	</tr>
	<tr>
		<td>x-secondlife-owner-name</td>
		<td>[Legacy name](https://wiki.secondlife.com/wiki/Category:LSL_Avatar/Name) of the owner of the object</td>
		<td>Zeb Wyler</td>
	</tr>
	<tr>
		<td>x-secondlife-owner-key</td>
		<td>[UUID](https://wiki.secondlife.com/wiki/UUID) of the owner of the object</td>
		<td>01234567-89ab-cdef-0123-456789abcdef</td>
	</tr>
	<tr>
		<td>x-secondlife-object-name</td>
		<td>The name of the object containing the script</td>
		<td>Object</td>
	</tr>
	<tr>
		<td>x-secondlife-object-key</td>
		<td>The key of the object containing the script</td>
		<td>01234567-89ab-cdef-0123-456789abcdef</td>
	</tr>
	<tr>
		<td>x-secondlife-local-velocity</td>
		<td>The velocity of the object</td>
		<td>0.000000, 0.000000, 0.000000</td>
	</tr>
	<tr>
		<td>x-secondlife-local-rotation</td>
		<td>The rotation of the object containing the script</td>
		<td>0.000000, 0.000000, 0.000000, 1.000000</td>
	</tr>
	<tr>
		<td>x-secondlife-local-position</td>
		<td>The position of the object within the region</td>
		<td>(173.009827, 75.551231, 60.950001)</td>
	</tr>
	<tr>
		<td>user-agent</td>
		<td>The user-agent header sent by LSL Scripts. Contains Server version.</td>
		<td>Second Life LSL/16.05.24.315768 (http://secondlife.com)</td>
	</tr>
	<tr>
		<td>content-type</td>
		<td>The media type of the entity body.</td>
		<td>text/plain; charset=utf-8</td>
	</tr>
	<tr>
		<td>accept-charset</td>
		<td>Acceptable character sets from the server. Q being the quality expected when sending the different character sets.</td>
		<td>utf-8;q=1.0, \*;q=0.5</td>
	</tr>
	<tr>
		<td>accept</td>
		<td>Media types the server will accept.</td>
		<td>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</td>
	</tr>
	<tr>
		<td>accept-encoding</td>
		<td>Acceptable content encodings for the server.</td>
		<td>deflate, gzip</td>
	</tr>
	<tr>
		<td>host</td>
		<td>The internet host being requested.</td>
		<td>secondlife.com</td>
	</tr>
	<tr>
		<td colspan="3">

			:::note
			Certain server environments (CGI) place 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". This depends solely on the HTTP server used to process the request and cannot be controlled via LSL.
			:::

			:::note
			[RFC 2616 § 4.2](https://datatracker.ietf.org/doc/html/rfc2616#section-4.2) defines HTTP header field names as case-insensitive. The capitalization of header field names shown above is not guaranteed; for example, "X-SecondLife-Object-Name" may be received as "X-Secondlife-Object-Name". See [BUG-5094](https://jira.secondlife.com/browse/BUG-5094) for an instance of ISPs recapitalizing headers. This behavior was also observed when testing in 2026.
			:::

		</td>
		<td></td>
		<td></td>
	</tr>
</table>

## Caveats

- Header information becomes inaccessible after 30 seconds or if [llHTTPResponse](/functions/llHTTPResponse/) is called.
- Function returns an empty string in any context outside the [http_request](/events/http_request/) event. For instance, it cannot be used in the [http_response](/events/http_response/) event.
- Custom headers are not supported, only the 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 lower case (or it will match nothing). All header names are converted to lower case when they are received.
- When making a request...
- 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
- In order 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

## Examples

<details open>
<summary>Example 1</summary>

```lsl collapse={1-40, 46-51}
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);

            llOwnerSay("body:\n" + body);
            llHTTPResponse(id, 200, body);
        }
    }
}
```

</details>

## Notes

- There is no specific function to set HTTP headers. Use [llHTTPRequest](/functions/llHTTPRequest/) with [HTTP_CUSTOM_HEADER](/constants/HTTP_CUSTOM_HEADER/) for requests. There is no way to set headers for responses.

## History

- SVN:1836 r112899 Trunk

## See also

### Functions

- [llGetFreeURLs](/functions/llGetFreeURLs/)
- [llRequestURL](/functions/llRequestURL/)
- [llRequestSecureURL](/functions/llRequestSecureURL/)
- [llReleaseURL](/functions/llReleaseURL/)
- [llHTTPResponse](/functions/llHTTPResponse/)

### Events

- [http_request](/events/http_request/)

### Articles

- [LSL http server](https://wiki.secondlife.com/wiki/LSL_http_server)
- [Wikipedia:List of HTTP headers](https://en.wikipedia.org/wiki/List_of_HTTP_headers)

---

*Source: [LlGetHTTPHeader](https://wiki.secondlife.com/wiki/LlGetHTTPHeader) on the Second Life Wiki. Content from the Second Life Wiki articles LlGetHTTPHeader (revision 1219023, 2026-09-08) and Template:LSL Constants/HTTP Headers (revision 1218827, 2026-05-04), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llGetHTTPHeader/
