LSL HTTP server/design

Goals

Create an alternative to the XMLRPC server and email gateway for communication with LSL scripts initiated from outside Second Life that is easy to use and scalable. Extra bonus for enabling LSL -> LSL communication at the same time.

Design

(Updated by Kelly Linden 11:19, 2 September 2008 (PDT))

This design is in flux during development. Please comment on the discussion page, as comments here tend to get lost when the design is updated. Thanks.

URLs / Namespace

url: http://sim3015.aditi.lindenlab.com:12046/cap/3ff4f3f2-ea08-76c1-cef6-a22b4a573a7c
request: curl http://sim3015.aditi.lindenlab.com:12046/cap/3ff4f3f2-ea08-76c1-cef6-a22b4a573a7c{untrusted-arg}
{untrusted-arg} examples: /foo/bar, ?foo=bar, /foo/bar?one=1

LSL

Request a new LSL Server public URL.
An http_request event will be triggered with success or failure and include the returned key
lsl: request_id = llRequestURL(); 
Similar to llRequestURL except requests an HTTPS / SSL URL.
An http_request event will be triggered with success or failure and include the returned key
lsl: request_id = llRequestSecureURL(); 
Clear the specific URL, used for both secure and non-secure URLs.
lsl: llReleaseURL("http://sim3015.aditi.lindenlab.com:12046/cap/3ff4f3f2-ea08-76c1-cef6-a22b4a573a7c");
Event triggered when an URL is hit:
  • id is unique to this request
  • Supported methods are GET/POST/PUT/DELETE
  • body: The body of the request.
Event also triggered with response to llRequestURL and llRequestSecureURL
  • id matches the key returned by llRequestURL or llRequestSecureURL
  • method == URL_REQUEST_GRANTED for success, URL_REQUEST_DENIED for failure to get an URL
  • body is the public URL. If unable to get a public URL body will be empty.
Send body to the requester with status code status
  • id is the id from http_request that maps to the specific request
Returns the string for the specified header in the specified request
  • Supported headers are:
  • "x-script-url": The base url, as originally recieved from llRequestPublicURL
  • "x-path-info": Any trailing path information from the requested url
  • "x-query-string": Any query arguments, the text past a ? in the url
  • "x-forwarded-for": The host that made the request
  • "user-agent": The user-agent header as reported by the requester
requested url: https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322/foo/bar?arg=gra
x-script-url: https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322
x-path-info: /foo/bar
x-query-string: arg=gra
  • CHANGED_REGION_RESTART: New changed() event triggered on region startup.
Returns the number of URLs available to this script.

Simulator

What the simulator needs to do:

  • Caps will automatically be revoked when the region goes down.
  • When the script is reset, resaved or deleted.
  • Object removed from world
  • Object region change
  • Object owner change
  • Region startup (clear all by region)
  • Script request (llReleasePublicURL)
Goal: Scripts should be able to know when public urls are lost and recover from that loss
  • Existing events: default/state_entry (new script), on_rez, changed(region cross, owner)
  • New events: cap server is restarted, region is restarted
  • This is a first use for a more general Limited Script Resource system that should eventually also handle script memory and cpu cycles.
  • Not all requests for an url will succeed, the scripter is expected to handle the failure case.
  • The number of available urls will be based on the amount of land owned in the region
  • integer llGetFreeURLs() returns how many URLs are available.

Cap Server

http://sim3015.aditi.lindenlab.com:12046/cap/3ff4f3f2-ea08-76c1-cef6-a22b4a573a7c
https://sim3015.aditi.lindenlab.com:12043/cap/a7717681-2c04-e4ac-35e3-1f01c9861322
request: http://sim3015.aditi.lindenlab.com:12046/cap/3ff4f3f2-ea08-76c1-cef6-a22b4a573a7c/foo/bar?one=1
forwarded to: <internal_url>
  w/ headers: x-script-url: http://sim3015.aditi.lindenlab.com:12046/cap/3ff4f3f2-ea08-76c1-cef6-a22b4a573a7c
              x-path-info: /foo/bar
              x-query-string: one=1

Questions / Issues

Interface Requirements

Performance Requirements

This should add no database, assetserver or viewer load.

Simulator:

It would be nice if this could happen before the simulator on a per-cap basis, but throttling in the simulator handler would probably work as well.

Capserver:

TODO:

We currently have 2 XMLRPC servers each processing about 30-40 concurrent requests.
I don't know the actual rate of requests, but I do know that we start failing at ~150
concurrent requests (out of a theoretical max of 200) per server, or ~300 total.
Kelly Linden 12:52, 14 May 2008 (PDT)

Security Impact

Creating a server accessible in any way from outside needs to be done with care. The cap server already does this, and security concerns should already be handled here. This isn't something to take for granted though.

Limitations

Interactions

Testing

TODO: Export internal test plan pages.

Previous Design

Previous design and comments