Difference between revisions of "Http request"

From Second Life Wiki
Jump to navigation Jump to search
(Kelly confirmed a brief service interruption at approx 0625 SLT was expected behaviour in his OH today.)
m
Line 2: Line 2:
|event=http_request|event_id=33|event_delay
|event=http_request|event_id=33|event_delay
|p1_type=key|p1_name=request_id|p1_desc=HTTP request id for response use, and function response identification.
|p1_type=key|p1_name=request_id|p1_desc=HTTP request id for response use, and function response identification.
|p2_type=string|p2_name=method|p2_desc=GET, POST, PUT
|p2_type=string|p2_name=method|p2_desc=GET, POST, PUT, DELETE
|p3_type=string|p3_name=body|p3_desc=Contents of the request.
|p3_type=string|p3_name=body|p3_desc=Contents of the request.
|event_desc=Triggered when task receives an HTTP request.
|event_desc=Triggered when task receives an HTTP request.

Revision as of 08:58, 8 July 2012

Description

Event: http_request( key request_id, string method, string body ){ ; }

Triggered when task receives an HTTP request.

• key request_id HTTP request id for response use, and function response identification.
• string method GET, POST, PUT, DELETE
• string body Contents of the request.

Specification

See LSL_http_server for full specification.

Caveats

  • body is limited to 2048 bytes; anything longer will be truncated to 2048 bytes.
  • headers (accessed with llGetHTTPHeader) are limited to 255 bytes.
  • There is a limit of 64 pending http_request
  • body is not sent with the request unless the method is set to POST or PUT.
  • Requests made at approx 0625 SLT may fail with a 503 status code, with "ERROR: The requested URL could not be retrieved", and "(111) Connection refused" in the body of the response. This has been confirmed as expected behaviour by Kelly, due to the nightly maint & log rotation. It does reliably impact object to object HTTP at that time, and quite probably may impact object to/from web around the same time. The interruption in service is fairly brief, and the precise timing may vary as LL adjust their nightly maint processes, or due to server load.


Examples

See LSL_http_server/examples for some examples from the feature design phase. <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);
           }
           else if (method == URL_REQUEST_DENIED)
           {
               llSay(0, "Something went wrong, no url. " + body);
           }
       }
       else
       {
           llHTTPResponse(id, 200, body);
       }
   }

}</lsl>

See Also

Functions

•  llRequestURL Request a new LSL Server public URL
•  llRequestSecureURL Request a new LSL Server public URL
•  llReleaseURL Release a URL
•  llHTTPResponse For replying to HTTP requests
•  llGetHTTPHeader Returns the requested HTTP header's value
•  llEscapeURL
•  llUnescapeURL

Deep Notes

Issues

All Issues

~ Search JIRA for related Issues
   Design: LSL http_server

Signature

event void http_request( key request_id, string method, string body );