HttpResponseMessage Kelas

Definisi

Mewakili pesan respons HTTP termasuk header, kode status, dan data.

public ref class HttpResponseMessage sealed : IClosable, IStringable
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Web.Http.IHttpResponseMessageFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class HttpResponseMessage final : IClosable, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Web.Http.IHttpResponseMessageFactory, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class HttpResponseMessage final : IClosable, IStringable
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Web.Http.IHttpResponseMessageFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class HttpResponseMessage : System.IDisposable, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Web.Http.IHttpResponseMessageFactory), 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class HttpResponseMessage : System.IDisposable, IStringable
function HttpResponseMessage(statusCode)
Public NotInheritable Class HttpResponseMessage
Implements IDisposable, IStringable
Warisan
Object Platform::Object IInspectable HttpResponseMessage
Atribut
Penerapan

Persyaratan Windows

Rangkaian perangkat
Windows 10 (diperkenalkan dalam 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v1.0)

Keterangan

Cara umum untuk mendapatkan httpResponseMessage adalah dari nilai pengembalian untuk salah satu metode DeleteAsync, GetAsync, PostAsync , PutAsync, atau SendRequestAsync pada objek HttpClient .

Konstruktor

HttpResponseMessage()

Menginisialisasi instans baru kelas HttpResponseMessage .

HttpResponseMessage(HttpStatusCode)

Menginisialisasi instans baru kelas HttpResponseMessage dengan HttpStatusCode tertentu.

Properti

Content

Mendapatkan atau mengatur konten pesan respons HTTP pada objek HttpResponseMessage .

Headers

Mendapatkan kumpulan header respons HTTP yang terkait dengan HttpResponseMessage yang dikirim oleh server.

IsSuccessStatusCode

Mendapatkan nilai yang menunjukkan apakah respons HTTP berhasil.

ReasonPhrase

Mendapatkan atau mengatur frasa alasan yang biasanya dikirim oleh server bersama dengan kode status.

RequestMessage

Mendapatkan atau mengatur pesan permintaan yang mengarah ke pesan respons ini.

Source

Mendapatkan sumber data yang diterima di HttpResponseMessage.

StatusCode

Mendapatkan atau mengatur kode status respons HTTP.

Version

Mendapatkan atau mengatur versi protokol HTTP yang digunakan pada objek HttpResponseMessage .

Metode

Close()

Menutup instans HttpResponseMessage dan merilis sumber daya yang dialokasikan.

Dispose()

Melakukan tugas yang ditentukan aplikasi yang terkait dengan membebaskan, melepaskan, atau mereset sumber daya yang tidak terkelola.

EnsureSuccessStatusCode()

Memberikan pengecualian jika properti HttpResponseMessage.IsSuccessStatusCode untuk objek respons HTTP adalah false; jika itu true, maka tidak ada pengecualian yang dilemparkan.

ToString()

Mengembalikan string yang mewakili objek HttpResponseMessage saat ini.

Berlaku untuk

Lihat juga