Main Content

matlab.net.http.StatusCode 클래스

네임스페이스: matlab.net.http

HTTP 응답의 상태 코드

설명

StatusCode 열거형 클래스는 상태 코드에 대한 ID를 제공합니다. 다음 목록은 2018년 9월 21일자의 IANA HTTP 상태 코드 레지스트리(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 웹사이트로 전송합니다.

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

이 웹사이트에서는 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 메서드(char, string, getReasonPhrase, 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에 개발됨