http_response(key request_id, integer status, list metadata, string body)
handler is invoked when an HTTP
response is received for a pending llHTTPRequest
request or if a pending request fails or times out. Note that every script with a http_response
handler in a prim will receive this event, not just the script that sent the llHTTPRequest
is set to the same value
as the key returned
by the llHTTPRequest
which initiated the call
is set to an HTTP status code either returned in the HTTP response or detailing the error which caused the request to fail. 499 seems to indicate a failure to establish a TCP connection while 0 likely means that the connection was established but the HTTP reply was invalid. 499 can also indicate that the target has an invalid SSL certificate and you turned verification on, and also you receive a 499 when no response is received after a certain time, which currently seems to be set to 60 seconds. 503 can indicate a DNS lookup failure.
These status codes should match the HTTP specification. Those are listed here. A normal (successful) request should get a status of 200 unless something funky happened.
is filled with <key, value>
pairs describing the response. Currently, the only key returned is HTTP_BODY_TRUNCATED
with a value equal to the point at which the response was truncated in bytes
is set to the body of the HTTP response as long as the response includes a "Content-Type" header specifying a text mime type. If a mime type is not specified or the type is not a text
type, body is set to "Unsupported or unknown Content-Type." If the "Content-Type" header specifies a character
set, body will be set to the body of the response transcoded to UTF-8
, or to "Unsupported or unknown character set." if the character set is unsupported. The body is currently limited to 2048 bytes.
Remember that "\n" in LSL is converted to a newline at compile time, and that your server's code may have a different character than \n for newlines. You should check your server's documentation for the proper method to add new lines, your millage may vary.
Simple script for reading data as it is presented from your web server:
//Ice Brodie's http text output script
//This script requests from our data source (URL) and echoes out what it sends to the owner of the script
//I use this to test my PHP apps personally, it's a simple debugging application so I release it publicly
//You may use, redistribute, modify, copy however you feel would be useful
key http;//This stores the HTTP request we send.
http=llHTTPRequest(URL,  ,"");
http_response(key id,integer status, list meta, string body)
//This turns newline characters char(10) into new lines in chat
//These are Unix/LSL style end of lines, use \r\n in place of \n for
// Windows style end of line from web server.