Difference between revisions of "LlGetHTTPHeader"
Jump to navigation
Jump to search
m |
m |
||
Line 8: | Line 8: | ||
|return_text=that is the value for '''header''' for '''request_id'''. | |return_text=that is the value for '''header''' for '''request_id'''. | ||
|spec= | |spec= | ||
=== | ===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 {{HoverTextStyle|style=color:green;|<nowiki>https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322</nowiki>|2={{String|x-script-url}} = {{String|https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322}}}}{{HoverTextStyle|style=color:blue;|/foo/bar|2={{String|x-path-info}} = {{String|/foo/bar}}}}?{{HoverTextStyle|style=color:red;|1=arg=gra|2={{String|x-query-string}} = {{String|1=arg=gra}}}}] | Sample URL: [https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322/foo/bar?arg=gra {{HoverTextStyle|style=color:green;|<nowiki>https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322</nowiki>|2={{String|x-script-url}} = {{String|https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322}}}}{{HoverTextStyle|style=color:blue;|/foo/bar|2={{String|x-path-info}} = {{String|/foo/bar}}}}?{{HoverTextStyle|style=color:red;|1=arg=gra|2={{String|x-query-string}} = {{String|1=arg=gra}}}}] | ||
Line 31: | Line 33: | ||
{{!}} IP address of the host that made the request | {{!}} IP address of the host that made the request | ||
{{!}} | {{!}} | ||
{{!}}} | |||
===Common Headers=== | |||
{{{!}} class="lltable" border="1" | |||
! header | |||
! description | |||
! example | |||
{{!}}- | {{!}}- | ||
{{!}} "user-agent" | {{!}} "user-agent" | ||
Line 36: | Line 46: | ||
{{!}} | {{!}} | ||
{{!}}} | {{!}}} | ||
|caveats=* LSL is not a CGI environment | |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". | ** "Content-Type" is an example of a normal header name, in a CGI environment the name would be "HTTP_CONTENT_TYPE". |
Revision as of 06:56, 14 July 2009
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: string llGetHTTPHeader( key request_id, string header );0.0 | Forced 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 |
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.
Examples
<lsl> 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) { llSay(0,"URL: " + body); if(llGetAgentSize(llGetOwner())) llLoadURL(llGetOwner(), body); } else if (method == URL_REQUEST_DENIED) { llSay(0, "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); llSay(0,header + ": " + llGetHTTPHeader(id, header)); } llSay(0, "body: " + body); llHTTPResponse(id, 200, body); } }
}
</lsl>See Also
Events
• | http_request |
Functions
• | llGetFreeURLs | |||
• | llRequestURL | |||
• | llRequestSecureURL | |||
• | llReleaseURL | |||
• | llHTTPResponse |
Articles
• | LSL http server | |||
• | ![]() |