Difference between revisions of "LlRequestURL"

From Second Life Wiki
Jump to navigation Jump to search
Line 8: Line 8:
|caveats=*When a region is (re)started all [[http_request|HTTP server]] URLs are automatically released and invalidated.
|caveats=*When a region is (re)started all [[http_request|HTTP server]] URLs are automatically released and invalidated.
**Use [[CHANGED_REGION_START]] to detect this so new URL can be requested.
**Use [[CHANGED_REGION_START]] to detect this so new URL can be requested.
*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 reboot) or it will be still active and you are losing free URLs.
*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.
|constants
|constants
|examples=
|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]].
|helpers
|helpers
|also_functions=
|also_functions=

Revision as of 08:04, 29 August 2009

Summary

Function: key llRequestURL( );
0.0 Forced Delay
10.0 Energy

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.

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

Signature

function key llRequestURL();