ヘルプ センターヘルプ センター
クラス: matlab.net.http.Message パッケージ: matlab.net.http
メッセージ ヘッダーへのフィールドの追加
msg = addFields(msg,fields)
msg = addFields(msg,fName,fValue)
msg = addFields(msg,fName1,fValue1,...,fNameN,fValueN)
msg = addFields(msg,index,___)
例
msg = addFields(msg,fields) は fields を各メッセージのヘッダーの最後に追加し、更新されたメッセージを返します。
msg
fields
addFields は重複フィールドがあるかどうかをチェックしませんが、RequestMessage の send メソッドおよび complete メソッドは不適切な重複を拒否することがあります。
addFields
RequestMessage
send
complete
send メソッドまたは complete メソッドが特定のヘッダー フィールドを自動的に追加しないようにするには、そのフィールドについて、空 ([]) の Value プロパティを指定して addFields を呼び出します。
[]
Value
msg = addFields(msg,fName,fValue) は、名前 fName と値 fValue をもつフィールドを追加します。
fName
fValue
msg = addFields(msg,fName1,fValue1,...,fNameN,fValueN) は、fName と fValue のペアの引数で指定されるフィールドを、指定された順序で追加します。
msg = addFields(msg,index,___) は index の位置にフィールドを挿入し、前述の構文に任意の入力引数を含めることができます。
index
すべて展開する
matlab.net.http.Message
メッセージ。matlab.net.http.Message オブジェクトとして指定します。
matlab.net.http.HeaderField
追加するフィールド。1 つ以上の matlab.net.http.HeaderField オブジェクトのベクトルまたはコンマ区切りリストとして指定します。
例: matlab.net.http.HeaderField('Accept','text/plain')
matlab.net.http.HeaderField('Accept','text/plain')
ヘッダー フィールド名。string として指定します。
例: 'Accept'
'Accept'
ヘッダー フィールド値。string または fName に有効なタイプとして指定します。フィールドに既定値を使用するには、fValue を '' に設定します。最後の値がない場合は、[] と指定するのと同じになります。
''
例: 'text/plain'
'text/plain'
メッセージ ヘッダー内の位置。整数として指定します。index がヘッダーの長さよりも大きいか、または index が 0 の場合、メソッドは最後にフィールドを追加します。index が負数の場合、メソッドはヘッダーの最後からカウントします。
例: -1 は最後のフィールドの前に fields を挿入します。
-1
値 'text/plain' をもつ Accept ヘッダー フィールドを作成し、既定の要求メッセージに追加します。
field = matlab.net.http.HeaderField('Accept','text/plain'); m = matlab.net.http.RequestMessage('get'); msg = addFields(m,field); show(msg)
GET Accept: text/plain
2 つのヘッダー フィールドを要求メッセージに追加します。
m = matlab.net.http.RequestMessage('get'); msg = addFields(m,'Accept','text/plain','Cache-Control','no-store, no-cache'); show(msg)
GET Accept: text/plain Cache-Control: no-store, no-cache
2 つのヘッダー フィールドを含む要求メッセージを作成します。
m = matlab.net.http.RequestMessage('get'); msg = addFields(m,'Accept','text/plain','Cache-Control','no-store, no-cache');
メッセージの最後のヘッダー フィールドの前に、Content-Type ヘッダー フィールドを挿入します。
f = matlab.net.http.HeaderField('Content-Type','text/plain'); msg = addFields(msg,-1,f); show(msg)
GET Accept: text/plain Content-Type: text/plain Cache-Control: no-store, no-cache
R2016b で導入
matlab.net.http.HeaderField | matlab.net.http.RequestMessage
matlab.net.http.RequestMessage
この例の変更されたバージョンがあります。編集された方の例を開きますか?
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office