从HttpRequestMessage获取HTTP请求字符串

时间:2017-05-03 17:52:21

标签: c# dotnet-httpclient

我想获得我将要使用HttpRequestMessage发送的HTTP请求的“字符串”版本。有没有一种简单的方法可以做到这一点,还是我需要自己生成类似的东西?

HttpRequestMessage request = new HttpRequestMessage();
request.ToString();

得到这样的东西:

 GET https://test.com/ HTTP/1.1
 Accept-Encoding: gzip,deflate
 Content-Type: application/json
 Authorization: Basic Yasjkdhaksjdhakjdhak==
 Host: test.com
 Connection: Keep-Alive
 Content-Length: 0

0 个答案:

没有答案