HttpResponseMessage HttpResponseMessage HttpResponseMessage HttpResponseMessage Class

定义

表示包括状态代码和数据的 HTTP 响应消息。Represents a HTTP response message including the status code and data.

public ref class HttpResponseMessage : IDisposable
public class HttpResponseMessage : IDisposable
type HttpResponseMessage = class
    interface IDisposable
Public Class HttpResponseMessage
Implements IDisposable
继承
HttpResponseMessageHttpResponseMessageHttpResponseMessageHttpResponseMessage
实现

注解

若要获取的常用方法HttpResponseMessage来自之一HttpClient.SendAsync(HttpRequestMessage)方法。A common way to get an HttpResponseMessage is from one of the HttpClient.SendAsync(HttpRequestMessage) methods.

构造函数

HttpResponseMessage() HttpResponseMessage() HttpResponseMessage() HttpResponseMessage()

初始化 HttpResponseMessage 类的新实例。Initializes a new instance of the HttpResponseMessage class.

HttpResponseMessage(HttpStatusCode) HttpResponseMessage(HttpStatusCode) HttpResponseMessage(HttpStatusCode) HttpResponseMessage(HttpStatusCode)

初始化指定的 HttpResponseMessageStatusCode 类的新实例。Initializes a new instance of the HttpResponseMessage class with a specific StatusCode.

属性

Content Content Content Content

获取或设置 HTTP 响应消息的内容。Gets or sets the content of a HTTP response message.

Headers Headers Headers Headers

获取 HTTP 响应标头的集合。Gets the collection of HTTP response headers.

IsSuccessStatusCode IsSuccessStatusCode IsSuccessStatusCode IsSuccessStatusCode

获取一个值,该值指示 HTTP 响应是否成功。Gets a value that indicates if the HTTP response was successful.

ReasonPhrase ReasonPhrase ReasonPhrase ReasonPhrase

获取或设置通常由服务器发出的原因短语(与状态代码一起发出)。Gets or sets the reason phrase which typically is sent by servers together with the status code.

RequestMessage RequestMessage RequestMessage RequestMessage

获取或设置导致此响应消息的请求消息。Gets or sets the request message which led to this response message.

StatusCode StatusCode StatusCode StatusCode

获取或设置 HTTP 响应的状态代码。Gets or sets the status code of the HTTP response.

Version Version Version Version

获取或设置 HTTP 消息版本。Gets or sets the HTTP message version.

方法

Dispose() Dispose() Dispose() Dispose()

释放由 HttpResponseMessage 使用的非托管资源。Releases the unmanaged resources and disposes of unmanaged resources used by the HttpResponseMessage.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放由 HttpResponseMessage 使用的非托管资源,并可根据需要释放托管资源。Releases the unmanaged resources used by the HttpResponseMessage and optionally disposes of the managed resources.

EnsureSuccessStatusCode() EnsureSuccessStatusCode() EnsureSuccessStatusCode() EnsureSuccessStatusCode()

如果 HTTP 响应的 IsSuccessStatusCode 属性是 false,则引发异常。Throws an exception if the IsSuccessStatusCode property for the HTTP response is false.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

Extension Methods

ToMessage(HttpResponseMessage) ToMessage(HttpResponseMessage) ToMessage(HttpResponseMessage) ToMessage(HttpResponseMessage)

通过 Message 实例创建 HttpResponseMessage 实例。Creates a Message instance from an HttpResponseMessage instance.

适用于