Difference between revisions of "LlHTTPResponse"

From Second Life Wiki
Jump to navigation Jump to search
Line 12: Line 12:
* If '''body''' content greater than 2048 bytes, sent in response to [[llHTTPRequest]], will be truncated to 2048 bytes by [[http_response]] in the receiving script
* If '''body''' content greater than 2048 bytes, sent in response to [[llHTTPRequest]], will be truncated to 2048 bytes by [[http_response]] in the receiving script
** This limit does not apply to shared media {{HoverText|MOAP|Media On A Prim}}  
** This limit does not apply to shared media {{HoverText|MOAP|Media On A Prim}}  
* Returns 'content-type: text/plain' by default. Use [[llSetContentType]] to optionally return 'text/html' if being viewed by the object owner within a Second Life client.
|constants
|constants
|examples=
|examples=

Revision as of 14:33, 26 August 2011

Summary

Function: llHTTPResponse( key request_id, integer status, string body );

Responds to request_id with status and body.

• key request_id A valid HTTP request key.
• integer status HTTP Status (200, 400, 404, etc)
• string body Contents of the response.

The response need not be made inside the http_request event but if it does not happen in a timely fashion the request will time out (within 25 seconds).

Caveats

  • This call must be made by the script containing the http_request event where the request_id was received.
  • If body content greater than 2048 bytes, sent in response to llHTTPRequest, will be truncated to 2048 bytes by http_response in the receiving script
    • This limit does not apply to shared media MOAP
  • Returns 'content-type: text/plain' by default. Use llSetContentType to optionally return 'text/html' if being viewed by the object owner within a Second Life client.
All Issues ~ Search JIRA for related Bugs

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)
           {
               llOwnerSay("URL: " + body);
           }
           else if (method == URL_REQUEST_DENIED)
           {
               llOwnerSay("Something went wrong, no url. " + body);
           }
       }
       else
       {
           llHTTPResponse(id, 200, body);
       }
   }
}</lsl>

See Also

Events

•  http_request

Functions

•  llGetFreeURLs
•  llRequestURL
•  llRequestSecureURL
•  llReleaseURL
•  llGetHTTPHeader
•  llSetContentType

Articles

•  LSL http server

Deep Notes

History

Search JIRA for related Issues

Signature

function void llHTTPResponse( key request_id, integer status, string body );