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)

使用特定 HttpResponseMessage,初始化 StatusCode 類別的新執行個體。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.

TrailingHeaders TrailingHeaders TrailingHeaders TrailingHeaders

取得包含在 HTTP 回應中的尾端標頭集合。Gets the collection of trailing headers included in an HTTP response.

Version Version Version Version

取得或設定 HTTP 訊息版本。Gets or sets the HTTP message version.

方法

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

釋放 Unmanaged 資源,並處置 HttpResponseMessage 所使用的 Unmanaged 資源。Releases the unmanaged resources and disposes of unmanaged resources used by the HttpResponseMessage.

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

釋放 HttpResponseMessage 所使用的 Unmanaged 資源,並選擇性處置 Managed 資源。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 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

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

傳回代表目前物件的字串。Returns a string that represents the current object.

擴充方法

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

Message 執行個體建立 HttpResponseMessage 執行個體。Creates a Message instance from an HttpResponseMessage instance.

適用於