以字符串格式打印HttpResponseMessage

时间:2014-01-21 07:08:11

标签: c# httpclient

是否有任何好方法或构建函数以字符串格式打印HttpResponseMessage,如

HTTP/1.1 200 OK
ETag: "lGaP-E0memYDumK16YuUDM_6Gf0/V43j6azD55CPRGb9b6uytDYl61Y"
Content-Type: application/json; charset=UTF-8
Date: Tue, 22 Jan 2013 18:56:00 GMT
Expires: Tue, 22 Jan 2013 18:56:00 GMT
Cache-Control: private, max-age=0
Content-Length: 247

{
 "kind": "storage#objectAccessControl",
 "id": "example-bucket/obj1/allUsers",
 "selfLink": "https://www.googleapis.com/storage/v1beta2/b/example-bucket/o/obj1    /acl/allUsers",
 "bucket": "example-bucket",
 "object": "obj1",
 "entity": "allUsers",
 "role": "READER"
}

我可以做的一件事就是从HttpResponseMessage手动读取字段并以这种方式打印,但这对我来说似乎非常容易出错,我认为在C#中应该有一些标准的方法来执行此操作。

0 个答案:

没有答案