llRequestURL

From Second Life Wiki
Revision as of 09:04, 29 August 2009 by Simba Fuhr (talk | contribs)
Jump to navigation Jump to search

Summary

Function: key llRequestURL( );

Requests one HTTP:// url for use by this object. The http_request event is triggered with the results.
Returns a key that is the handle used for identifying the request in the http_request event.

Caveats

  • When a region is (re)started all HTTP server URLs are automatically released and invalidated.
  • An old URL MUST be released first by using llReleaseURL if you are requesting an new one (where the reason for is not a region restart) or it will be still active and you are losing free URLs.
All Issues ~ Search JIRA for related Bugs

Examples

Requesting a new URL after region restart: <LSL> default {

state_entry()
{
 //Requesting a URL
 llRequestURL();
}
changed(integer What)
{
 //Resgion restartet
 if (What & CHANGED_REGION_START)
 {
  //Request new URL
  llRequestURL();
 }
}
http_request(key ID, string Method, string Body)
{
 if (Method == URL_REQUEST_GRANTED)
 {
  //Saying URL to owner
  llOwnerSay(Body);
 }
 else if (Method == URL_REQUEST_DENIED)
 {
  llOwnerSay("No URLs free !");
 }
 else if (Method == "GET")
  {llHTTPResponse(ID, 200, "Hello there !");}
}

} </LSL> Here the old URL will be released anytime when the region restarts.

If you want to request a new URL and the region is not restarted you need to store the old one and release it manually before requesting a new one or your limit on free URLs will be down quick.

Try the following code ONLY if you can use all your URLs on your land. Removing the prim/script will release all URLs previous assigned. <LSL> default {

state_entry()
{
 //Requesting a URL
 llRequestURL();
}
http_request(key ID, string Method, string Body)
{
 if (Method == URL_REQUEST_GRANTED)
 {
  //Printing new URL and free adresses
  llSetText((string)llGetFreeURLs() + "\n" + Body, <1, 1, 1>, 1);
 }
 else if (Method == URL_REQUEST_DENIED)
 {
  llSetText("No URLs free !", <1, 0, 0>, 1);
 }
 else if (Method == "GET")
  {llHTTPResponse(ID, 200, "Hello there !");}
}

} </LSL> This script will, as you can see, use all URLs available on your land because it does not remove the old URLs before requesting a new one.

Just store the old URL in a global variable and release it with llReleaseURL.

See Also

Functions

•  llRequestSecureURL
•  llGetFreeURLs
•  llReleaseURL
•  llHTTPResponse
•  llGetHTTPHeader

Articles

•  LSL http server

Deep Notes

History

Search JIRA for related Issues

Signature

function key llRequestURL();