Sys.Net.WebRequest の executor プロパティ
更新 : 2007 年 11 月
関連付けられた Sys.Net.WebRequest インスタンスのエグゼキュータを取得または設定します。
メモ : |
---|
クライアント API プロパティのプロパティ値を取得または設定するには、名前のプレフィックスが get_ および set_ のプロパティ アクセサ メソッドを呼び出す必要があります。たとえば、cancel のプロパティの値を取得または設定するには、get_cancel メソッドまたは set_cancel メソッドを呼び出します。 |
var executor = MyWebRequest.get_executor();
myRequest.set_Executor(value);
パラメータ
パラメータ |
説明 |
---|---|
value |
Sys.Net.WebRequestExecutor の派生クラスのインスタンス。 |
戻り値
現在の WebRequestExecutor インスタンス。
例外
例外の種類 |
条件 |
---|---|
value に null は指定できません。 |
|
エグゼキュータが有効化された後に設定されました。 |
|
value が有効な WebRequestExecutor 型ではありません。 |
解説
WebRequest インスタンスの実行の完了後、executor プロパティは要求に関連付けられているアクティブなネットワーク エグゼキュータを返します。WebRequest インスタンスには、関連付けられているエグゼキュータからプログラムでアクセスできます。
executor プロパティは、カスタム ネットワーク エグゼキュータが必要な場合のみ設定してください。このプロパティを設定しなかった場合は、システムでは既定の Sys.Net.XmlHttpExecutor エグゼキュータが使用され、これが invoke メソッドが呼び出された後に設定されます。
WebRequest インスタンスに既に関連付けられているエグゼキュータが存在し、Web 要求が発行済みの場合は、executor プロパティを設定できません。myRequest.set_executor(myRequest.get_executor()) など、要求インスタンスに既に関連付けられているエグゼキュータを使用して executor プロパティを設定しようとすると、例外がスローされます。
使用例
エグゼキュータを設定する方法の例を次に示します。このコードは、WebRequest クラスの概要で説明しているコード例の一部です。
// This function sets the Web request
// executor, replacing the default one.
function WebRequestExecutor()
{
// Instantiate the WebRequest.
var wRequest = new Sys.Net.WebRequest();
// Create the executor. In this case it is an
// XMLHttpExecutor, equivalent to the default
// executor. But, you can create a custom one.
var executor = new Sys.Net.XMLHttpExecutor();
// Set the executor, replacing the default one.
// In this case the executor is equivalent to the
// default one.
wRequest.set_executor(executor);
// Get the current executor
var executor =
wRequest.get_executor();
alert("Response availabe: " + executor.get_responseAvailable())
}