“LlHTTPResponse”的版本间的差异
(创建页面,内容为“{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}} {{函数详情 |函数名 = Function: llHTTPResponse( key request_id, integer status, string bod…”) |
|||
| (未显示同一用户的2个中间版本) | |||
| 第13行: | 第13行: | ||
*This call must be made by the script containing the http_request event where the request_id was received. | *This call must be made by the script containing the http_request event where the request_id was received. | ||
*除了脚本大小之外,这个函数可以发送的数据量没有限制。 | *除了脚本大小之外,这个函数可以发送的数据量没有限制。 | ||
| − | + | 在接收脚本时,llhttprequest 可以截断响应长度。在使用它们进行 prim-to-prim 通信时要注意。 | |
*默认的响应是“ content-type: text/plain”。使用 llsetcontenttype 可以选择返回不同的类型,如“ text/html”。 | *默认的响应是“ content-type: text/plain”。使用 llsetcontenttype 可以选择返回不同的类型,如“ text/html”。 | ||
|示例= | |示例= | ||
| 第24行: | 第24行: | ||
changed(integer change) | changed(integer change) | ||
{ | { | ||
| − | if (change & (CHANGED_REGION_START | CHANGED_REGION | CHANGED_TELEPORT)) | + | if (change & (CHANGED_REGION_START|CHANGED_REGION | CHANGED_TELEPORT)) |
llResetScript(); | llResetScript(); | ||
} | } | ||
| 第68行: | 第68行: | ||
} | } | ||
} | } | ||
| − | <pre> | + | </pre> |
2020年8月20日 (四) 10:12的最新版本
| 首页 | 函数 | 事件 | 类型 | 操作符 | 常数 | Flow Control | Script Library | Categorized Library | Tutorials |
| 函数名 |
|---|
| Function: llHTTPResponse( key request_id, integer status, string body ); |
| 参数:
key request_id – A valid HTTP request key. integer status – HTTP Status (200, 400, 404, etc) string body – Contents of the response. |
| 返回值:用 status 和 body 响应 request _ id。 |
| 注意事项 |
|---|
*This call must be made by the script containing the http_request event where the request_id was received.
在接收脚本时,llhttprequest 可以截断响应长度。在使用它们进行 prim-to-prim 通信时要注意。
|
| 示例 |
|---|
示例一
string url;
default
{
changed(integer change)
{
if (change & (CHANGED_REGION_START|CHANGED_REGION | CHANGED_TELEPORT))
llResetScript();
}
state_entry()
{
llRequestURL();
}
touch_start(integer num_detected)
{
// PUBLIC_CHANNEL has the integer value 0
if (url != "")
llSay(PUBLIC_CHANNEL, "URL: " + url);
}
http_request(key id, string method, string body)
{
// http://en.wikipedia.org/wiki/Create,_read,_update_and_delete
list CRUDmethods = ["GET", "POST", "PUT", "DELETE"];
// it's bit-wise NOT ( ~ ) !!!
integer isAllowedMethod = ~llListFindList(CRUDmethods, [method]);
if (isAllowedMethod)
{
llHTTPResponse(id, 200, "Body of request below:\n" + body);
}
else if (method == URL_REQUEST_GRANTED)
{
// don't forget the trailing slash
url = body + "/";
llOwnerSay("URL: " + url);
}
else if (method == URL_REQUEST_DENIED)
{
llOwnerSay("Something went wrong, no URL.\n" + body);
}
else
{
llOwnerSay("Ummm... I have no idea what SL just did. Method=\""+method+"\"\n" + body);
}
}
}
|
| 相关函数 |
|---|
| llGetFreeURLs
llRequestURL llRequestSecureURL llReleaseURL llGetHTTPHeader llSetConteneType |
| 相关事件 |
|---|
| http request |