Difference between revisions of "Http response"

From Second Life Wiki
Jump to navigation Jump to search
(Added technical information only)
Line 11: Line 11:
! Description
! Description
{{!}}-
{{!}}-
{{!}} {{LSLG|HTTP_BODY_TRUNCATED}}
{{!}} [[HTTP_BODY_TRUNCATED]]
{{!}} 0
{{!}} 0
{{!}} integer
{{!}} integer
{{!}} Truncation point in bytes
{{!}} Truncation point in bytes
{{!}}}
{{!}}}
|spec
|spec=<h3>status 499</h3>
Besides the usual HTTP status codes, SL implements a special '''status''' code 499, which can indicates:
*Request timeout (60 seconds)
*SSL failure
*A space was present in the url (escape your URL with [[llEscapeURL]]).
|caveats
|caveats
|examples=<pre>key http_request_id;
|examples=<lsl>key http_request_id;


default
default
Line 34: Line 38:
         }
         }
     }
     }
}</pre>
}</lsl>
|helpers
|helpers
|also_header
|also_header

Revision as of 19:23, 29 March 2008

Description

Event: http_response( key request_id, integer status, list metadata, string body ){ ; }

Triggered when task receives a response to one of its llHTTPRequests

• key request_id Matches return from llHTTPRequest
• integer status HTTP code (like 404 or 200)
• list metadata List of HTTP_* constants and attributes
• string body

Specification

status 499

Besides the usual HTTP status codes, SL implements a special status code 499, which can indicates:

  • Request timeout (60 seconds)
  • SSL failure
  • A space was present in the url (escape your URL with llEscapeURL).
Constant Type Description
HTTP_BODY_TRUNCATED 0 integer Truncation point in bytes

Caveats


Examples

<lsl>key http_request_id;

default {

   state_entry()
   {
       http_request_id = llHTTPRequest("url", [], "");
   }
   http_response(key request_id, integer status, list metadata, string body)
   {
       if (request_id == http_request_id)
       {
           llSetText(body, <0,0,1>, 1);
       }
   }

}</lsl>

Notes

If for some reason while using llHTTPRequest/http_response you are unable to parse a known good RSS feed or some other form of web contents, you will need to work around it outside of SecondLife. This is unlikely to change in the near future since checking the headers requires more overhead at the simulator level.

Status 499 is never returned by a website in response to an llHTTPRequest call. This status indicates that the request timed out and the sim closed the connection before any response was received.

Some useful HTTP headers sent are:

  • HTTP_X_SECONDLIFE_LOCAL_POSITION
  • HTTP_X_SECONDLIFE_LOCAL_ROTATION
  • HTTP_X_SECONDLIFE_LOCAL_VELOCITY
  • HTTP_X_SECONDLIFE_OBJECT_KEY
  • HTTP_X_SECONDLIFE_OBJECT_NAME
  • HTTP_X_SECONDLIFE_OWNER_KEY
  • HTTP_X_SECONDLIFE_OWNER_NAME
  • HTTP_X_SECONDLIFE_REGION
  • HTTP_X_SECONDLIFE_SHARD

See Also

Functions

•  llHTTPRequest

Deep Notes

Signature

event void http_response( key request_id, integer status, list metadata, string body );