LlSetContentType/ja

From Second Life Wiki
Jump to navigation Jump to search

要約

関数: llSetContentType( key request_id, integer content_type );

LSL HTTPサーバーレスポンスの"Wikipedia logo"インターネットメディアタイプを設定します。[1]

• key request_id http_request() のkey
• integer content_type その後のllHTTPResponse(request_id, ...)全てで用いるメディアタイプ

コンテンツタイプ Content-Type
CONTENT_TYPE_TEXT 0 text/plain
CONTENT_TYPE_HTML 1 text/html
CONTENT_TYPE_XML 2 application/xml
CONTENT_TYPE_XHTML 3 application/xhtml+xml
CONTENT_TYPE_ATOM 4 application/atom+xml
CONTENT_TYPE_JSON 5 application/json
CONTENT_TYPE_LLSD 6 application/llsd+xml
CONTENT_TYPE_FORM 7 application/x-www-form-urlencoded
CONTENT_TYPE_RSS 8 application/rss+xml

警告

  • この設定は以下の場合に無視されます。
    1. ウェブブラウザがSecond Life clientでない場合。
    2. (SLクライアントでログインしてページを表示している)ユーザーがオブジェクトのオーナーでない場合。
  • グループ所有のオブジェクトでは機能しません。
  • When using CONTENT_TYPE_HTML, this setting will be ignored unless all of these conditions are met:
    1. the web browser is the Second Life client
    2. the user (logged into the SL client viewing the page) is the owner of the object.
    3. the user (logged into the SL client viewing the page) is connected to the region the object is located in
    Obviously this is not compatible with group owned objects. One way around this limitation would be to temporarily attach a repeater.
All Issues ~ Search JIRA for related Bugs

サンプル

key url_request;

string HTML_BODY =
"<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>

<p>My first paragraph.</p>

</body>
</html>";

default
{
    state_entry()
    {
        url_request = llRequestURL();
    }

    http_request(key id, string method, string body)
    {
        key owner = llGetOwner();
        vector ownerSize = llGetAgentSize(owner);

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

            //  if owner in sim
                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
        {
            llOwnerSay("request body:\n" + body);

        //  if owner in sim
            if (ownerSize)//  != ZERO_VECTOR
            {
                llSetContentType(id, CONTENT_TYPE_HTML);
                llHTTPResponse(id, 200, HTML_BODY);
            }
            else
            {
                llSetContentType(id, CONTENT_TYPE_TEXT);
                llHTTPResponse(id, 200, "OK");
            }
        }
    }
}

注意点

  • A workaround for displaying html to non-owners inworld can be found here.

関連項目

イベント

•  http_request
•  http_response

関数

•  llHTTPResponse

記事

•  LSL HTTP server
•  HTML HUD Demo

特記事項

経緯

  • Released August 16, 2011.
  • SCR-394 - Documentation revised but no change in functionality.
Search JIRA for related Issues

脚注

  1. ^ この関数はその後に起こる全てのllHTTPResponseレスポンスの"Content-Type"ヘッダーを設定します。

Signature

function void llSetContentType( key request_id, integer content_type );

コメント

クライアントと所有者の制限は、プリムからウェブサイトを運営する可能性をほぼ取り去ります。

この翻訳は 原文 と比べて古いですか?間違いがありますか?読みにくいですか?みんなで 修正 していきましょう! (手順はこちら)
この項目はあなたにとって参考にならない項目ですか?もしかしたらLSL Wikiの関連した項目が参考になるかもしれません。