Main Content

matlab.net.http.StatusCode クラス

パッケージ: matlab.net.http

HTTP 応答のステータス コード

説明

StatusCode 列挙型クラスはステータス コードの識別子を提供します。このリストの出典は、IANA の 2018-09-21 バージョンの『HTTP Status Code Registry』(https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml) です。

整数
表現
列挙型メンバー名整数
表現
列挙型メンバー名整数
表現
列挙型メンバー名
100Continue400BadRequest500InternalServerError
101SwitchingProtocols401Unauthorized501NotImplemented
102Processing402PaymentRequired502BadGateway
103EarlyHints403Forbidden503ServiceUnavailable
200OK404NotFound504GatewayTimeout
201Created405MethodNotAllowed505HTTPVersionNotSupported
202Accepted406NotAcceptable506VariantAlsoNegotiates
203NonAuthoritativeInformation407ProxyAuthenticationRequired507InsufficientStorage
204NoContent408RequestTimeout508LoopDetected
205ResetContent409Conflict509Unassigned
206PartialContent410Gone510NotExtended
207MultiStatus411LengthRequired511HTTPVersionNotSupported
208AlreadyReported412PreconditionFailed451UnavailableForLegalReasons
226IMUsed413PayloadTooLarge  
  414URITooLong  
300MultipleChoices415UnsupportedMediaType  
301MovedPermanently416RangeNotSatisfiable  
302Found417ExpectationFailed  
303SeeOther421MisdirectedRequest  
304NotModified422UnprocessableEntity  
305UseProxy423Locked  
306SwitchProxy424FailedDependency  
307TemporaryRedirect426UpgradeRequired  
308PermanentRedirect428PreconditionRequired  
  429TooManyRequests  
  431RequestHeaderFieldsTooLarge  

メソッド

すべて展開する

すべて折りたたむ

ステータス コードを使用してエラー情報を提供します。

PUT メッセージを mathworks.com Web サイトに送信します。

uri = matlab.net.URI('https://www.mathworks.com');
header = matlab.net.http.field.ContentTypeField('text/plain');
req = matlab.net.http.RequestMessage('put',header,'Data');
resp = send(req, uri);

この Web サイトは PUT メソッドを許可しません。ユーザー向けのメッセージを表示します。

sc = resp.StatusCode;
if sc ~= matlab.net.http.StatusCode.OK
    disp([getReasonPhrase(getClass(sc)),': ',getReasonPhrase(sc)])
    disp(resp.StatusLine.ReasonPhrase)
end
Client Error: Method Not Allowed
Method Not Allowed

StatusCode メソッド (charstringgetReasonPhrase および getClass) は、コードとその意味についての情報を提供します。要件に基づいてメソッドを選択します。

応答メッセージにステータス コード 307 が含まれているとします。この例を実行するために、コードを作成します。

sc = matlab.net.http.StatusCode(307);

char メソッドおよび getReasonPhrase メソッドを使用して、ステータス コードの意味のテキストを返します。getReasonPhrase メソッドはメッセージ内で使用できる句を作成します。

txt = char(sc)
txt = 
'TemporaryRedirect'
msg = getReasonPhrase(sc)
msg = 
'Temporary Redirect'

string メソッドを使用して、ステータス コードの整数値を string として返します。

value = string(sc)
value = 
"307"

コードがステータス クラスに基づいてステータス コードを処理する場合は、getClass メソッドを使用します。

class = getClass(sc)
class = 
  StatusClass enumeration

    Redirection

enumeration matlab.net.http.StatusCode
Enumeration members for class 'matlab.net.http.StatusCode':

    Continue
    SwitchingProtocols
    Processing
    EarlyHints
    OK
    Created
    Accepted
    NonAuthoritativeInformation
    NoContent
    ResetContent
    PartialContent
    MultiStatus
    AlreadyReported
    IMUsed
    MultipleChoices
    MovedPermanently
    Found
    SeeOther
    NotModified
    UseProxy
    SwitchProxy
    TemporaryRedirect
    PermanentRedirect
    BadRequest
    Unauthorized
    PaymentRequired
    Forbidden
    NotFound
    MethodNotAllowed
    NotAcceptable
    ProxyAuthenticationRequired
    RequestTimeout
    Conflict
    Gone
    LengthRequired
    PreconditionFailed
    PayloadTooLarge
    URITooLong
    UnsupportedMediaType
    RangeNotSatisfiable
    ExpectationFailed
    MisdirectedRequest
    UnprocessableEntity
    Locked
    FailedDependency
    UpgradeRequired
    PreconditionRequired
    TooManyRequests
    RequestHeaderFieldsTooLarge
    UnavailableForLegalReasons
    InternalServerError
    NotImplemented
    BadGateway
    ServiceUnavailable
    GatewayTimeout
    HTTPVersionNotSupported
    VariantAlsoNegotiates
    InsufficientStorage
    LoopDetected
    Unassigned
    NotExtended
    NetworkAuthenticationRequired

バージョン履歴

R2016b で導入