Difference between revisions of "Http response"

From Second Life Wiki
Jump to navigation Jump to search
Line 18: Line 18:
|spec
|spec
|caveats
|caveats
|examples
|examples=<pre>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);
        }
    }
}</pre>
|helpers
|helpers
|also_header
|also_header

Revision as of 19:54, 11 February 2007

Description

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

Triggered when task receives a response to one of it's 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
Constant Value Type Description
HTTP_BODY_TRUNCATED 0 integer Truncation point in bytes

Caveats


Examples

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);
        }
    }
}

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.

See Also

Functions

Deep Notes

Signature

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