LlGetHTTPHeader

来自人工智能助力教育知识百科
Qmf讨论 | 贡献2021年1月25日 (一) 08:01的版本 (创建页面,内容为“{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}} {{函数详情 |函数名 = Function: string llGetHTTPHeader( key request_id, string header ) |…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

Template:Needs Translation/


函数名
Function: string llGetHTTPHeader( key request_id, string header )
参数:
  • key request_id–A valid HTTP request key.
  • string header–Lower case header value name.
返回值:返回一个字符串,该字符串是request_id的头的值。
注意事项
注意事项
示例
key url_request;
 
default
{
    state_entry()
    {
        url_request = llRequestURL();
    }
 
    http_request(key id, string method, string body)
    {
        if (url_request == id)
        {
        //  if you're usually not resetting the query ID
        //  now is a good time to start!
            url_request = "";
 
            if (method == URL_REQUEST_GRANTED)
            {
                llOwnerSay("URL: " + body);
 
                key owner = llGetOwner();
                vector ownerSize = llGetAgentSize(owner);
 
                if (ownerSize)//  != ZERO_VECTOR
                    llLoadURL(owner, "I got a new URL!", body);
            }
 
            else if (method == URL_REQUEST_DENIED)
                llOwnerSay("Something went wrong, no url:\n" + body);
        }
 
        else
        {
            list headerList = ["x-script-url",
                            "x-path-info", "x-query-string",
                            "x-remote-ip", "user-agent"];
 
            integer index = -llGetListLength(headerList);
            do
            {
                string header = llList2String(headerList, index);
                llOwnerSay(header + ": " + llGetHTTPHeader(id, header));
            }
            while (++index);
 
            llOwnerSay("body:\n" + body);
            llHTTPResponse(id, 200, body);
        }
    }
}
相关函数
llGetFreeURLs

llRequestURL llRequestSecureURL llReleaseURL llHTTPResponse

相关事件
http_request