主要内容

matlab.net.http.StatusCode类

包:matlab.net.http

HTTP响应中的状态代码

描述

StatusCode枚举类提供状态代码的标识符。本列表来自2018-09-21版本的IANA HTTP Status Code注册表,https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

整数翅,
界定
枚举成员名 整数翅,
界定
枚举成员名 整数翅,
界定
枚举成员名
One hundred. 继续 400 BadRequest 500 InternalServerError
101 SwitchingProtocols 401 未经授权的 501 NotImplemented
102 处理 402 PaymentRequired 502 BadGateway
103 EarlyHints 403 被禁止的 503 ServiceUnavailable
200 好吧 404 NotFound 504 GatewayTimeout
201 创建 405 MethodNotAllowed 505 HTTPVersionNot金宝appSupported
202 接受 406 NotAcceptable 506 VariantAlsoNegotiates
203 NonAuthoritativeInformation 407 ProxyAuthenticationRequired 507 InsufficientStorage
204 NoContent 408 RequestTimeout 508 LoopDetected
205 ResetContent 409 冲突 509 未赋值的
206 PartialContent 410 走了 510 NotExtended
207 MultiStatus 411 LengthRequired 511 HTTPVersionNot金宝appSupported
208 AlreadyReported 412 PreconditionFailed 451 UnavailableForLegalReasons
226 艾莫斯 413 PayloadTooLarge
414 URITooLong
300 MultipleChoices 415 Un金宝appsupportedMediaType
301 MovedPermanently 416 RangeNotSatisfiable
302 发现 417 ExpectationFailed
303 SeeOther 421 MisdirectedRequest
304 NotModified 422 UnprocessableEntity
305 UseProxy 423 锁着的
306 SwitchProxy 424 FailedDependency
307 TemporaryRedirect 426 UpgradeRequired
308 PermanentRedirect 428 PreconditionRequired
429 TooManyRequests
431 RequestHeaderFieldsTooLarge

方法

全部展开

例子

全部折叠

使用状态代码提供错误信息。

发送PUT消息到mathworks.com的网站。

uri = matlab.net.URI (“//www.tatmou.com”);头= matlab.net.http.field.ContentTypeField (“文本/普通”);要求= matlab.net.http.RequestMessage (“把”头,“数据”);rep = send(req, uri);

该网站不允许PUT方法。显示用户友好的信息。

sc = resp.StatusCode;如果sc ~= matlab.net.http.StatusCode.OK disp([getReasonPhrase(getClass(sc))]),“:”getReasonPhrase (sc)]) disp (resp.StatusLine.ReasonPhrase)结束
客户端错误:方法不允许方法不允许

StatusCode方法- - - - - -字符字符串getReasonPhrase,getClass-提供有关代码及其含义的信息。根据您的需求选择一种方法。

假设您的响应消息包含状态码307。要运行此示例,请创建代码。

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

使用字符getReasonPhrase方法返回状态代码含义的文本。的getReasonPhrase方法创建可以在消息中使用的短语。

txt = char (sc)
txt = ' TemporaryRedirect '
味精= getReasonPhrase (sc)
msg = '临时重定向'

使用字符串方法以返回状态码的整数值作为字符串。

值=字符串(sc)
value = " 307 "

如果您的代码基于状态类处理状态代码,则使用getClass方法。

类= getClass (sc)
class = StatusClass enumeration重定向
枚举matlab.net.http.StatusCode
类'matlab.net.http.StatusCode'的枚举成员:继续SwitchingProtocols Processing EarlyHints OK Created Accepted nonauthorativeinformation NoContent ResetContent PartialContent MultiStatus AlreadyReported IMUsed MultipleChoices movedpermanent Found SeeOther NotModified UseProxy SwitchProxy TemporaryRedirect PermanentRedirect BadRequest Unauthorized PaymentRequired Forbidden NotFound方法notalallowed NotAcceptable ProxyAuthenticationRequired RequestTimeout Conflict Gone LengthRequired PreconditionFailed payloadtoollarge uritolong Unsu金宝apppportedMediaType RangeNotSatisfiable ExpectationFailed misdirecteddrequest UnprocessableEntity Locked FailedDependency UpgradeRequired PreconditionRequired TooManyRequestsrequesttheaderfieldstoollarge UnavailableForLegalReasons InternalServerError NotImplemented BadGateway ServiceUnavailable GatewayTimeout HTTPVersionN金宝appotSupported VariantAlsoNegotiates InsufficientStorage LoopDetected Unassigned noextended NetworkAuthenticationRequired
介绍了R2016b