📜  c#代码示例中的http标头

📅  最后修改于: 2022-03-11 14:49:10.894000             🧑  作者: Mango

代码示例1
var client = new HttpClient();
var request = new HttpRequestMessage() {
    RequestUri = new Uri("http://www.someURI.com"),
    Method = HttpMethod.Get,
};
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain"));
var task = client.SendAsync(request)
    .ContinueWith((taskwithmsg) =>
    {
        var response = taskwithmsg.Result;

        var jsonTask = response.Content.ReadAsAsync();
        jsonTask.Wait();
        var jsonObject = jsonTask.Result;
    });
task.Wait();