Main Content

matlab.net.http.field.ContentTypeField クラス

名前空間: matlab.net.http.field
スーパークラス: matlab.net.http.HeaderField, matlab.net.http.field.MediaRangeField

HTTP Content-Type ヘッダー フィールド

説明

ContentTypeField オブジェクトは、要求メッセージまたは応答メッセージの HTTP ヘッダー フィールドです。フィールドには、メッセージ本文のコンテンツのタイプを示す 1 つのメディア タイプ指定が含まれます。詳細については、RFC 7231 Semantics and Content、セクション 3.1.1.5. の Content-Type (Internet Engineering Task Force の Web サイト上) を参照してください。

要求メッセージでは、Content-Type フィールドは MessageBody.Data プロパティで指定されたデータの変換方法を決定します。この変換の詳細については、HTTP データ型の変換を参照してください。要求メッセージに空でない本文が含まれていて Content-Type フィールドが含まれていない場合、MATLAB® はデータ型に基づいて Content-Type フィールドを作成します。

クラスの属性

Sealed
true

クラス属性の詳細については、クラスの属性を参照してください。

作成

説明

obj = matlab.net.http.field.ContentTypeField(value)Value プロパティを value に設定して、Content-Type ヘッダー フィールドを作成します。

プロパティ

すべて展開する

ヘッダー フィールド名。'Content-Type' として指定します。

属性:

GetAccess
public
SetAccess
public
Dependent
true

メディア タイプ。matlab.net.http.MediaType オブジェクト、または MediaType コンストラクターで受け入れ可能な string として指定します。Value は品質 ('q') パラメーターを含むことはできません。

例: 'text/html;charset=utf-8'

属性:

GetAccess
public
SetAccess
public

メソッド

すべて展開する

すべて折りたたむ

この例では、メッセージの Content-Type フィールドを読み取る方法を示します。

import matlab.net.*;
import matlab.net.http.*;

httpsUrl = 'https://requestserver.mathworks.com';
uri = URI(strcat(httpsUrl, '/assets/computerVision.jpg'));
req = RequestMessage('GET');
response = req.send(uri);
contentTypeField = response.getFields("Content-Type");
disp(contentTypeField)
  ContentTypeField with properties:

     Name: "Content-Type"
    Value: "image/jpeg"

バージョン履歴

R2016b で導入