本文整理汇总了C#中System.Net.Http.HttpResponseMessage.AsFormattedString方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponseMessage.AsFormattedString方法的具体用法?C# HttpResponseMessage.AsFormattedString怎么用?C# HttpResponseMessage.AsFormattedString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Http.HttpResponseMessage
的用法示例。
在下文中一共展示了HttpResponseMessage.AsFormattedString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HttpResponseMessageAsFormattedStringHandlesEmptyRequests
public void HttpResponseMessageAsFormattedStringHandlesEmptyRequests()
{
using (var httpRequest = new HttpResponseMessage())
{
var formattedString = httpRequest.AsFormattedString();
Assert.Contains("StatusCode: 200", formattedString);
}
}
示例2: HttpResponseMessageAsFormattedStringHandlesRequestsWithHeaders
public void HttpResponseMessageAsFormattedStringHandlesRequestsWithHeaders()
{
using (var httpRequest = new HttpResponseMessage(HttpStatusCode.OK))
{
httpRequest.Headers.Add("x-ms-version", "2013-11-01");
var formattedString = httpRequest.AsFormattedString();
Assert.Contains("StatusCode: 200", formattedString);
Assert.Contains("x-ms-version: 2013-11-01", formattedString);
}
}
示例3: LogsResponse
public void LogsResponse()
{
Log4NetTracingInterceptor logger = new Log4NetTracingInterceptor("app.config");
string invocationId = "12345";
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Accepted);
string expected = string.Format("DEBUG - invocationId: {0}\r\nresponse: {1}\r\n", invocationId,
response.AsFormattedString());
logger.ReceiveResponse(invocationId, response);
string actual = File.ReadAllText(logFileName);
Assert.Equal(expected, actual);
}
示例4: ReceiveResponse
public void ReceiveResponse(string invocationId, HttpResponseMessage response)
{
_logger.LogInformation(" response: {0}", response.AsFormattedString());
}
示例5: ReceiveResponse
/// <summary>
/// Receive an HTTP response.
/// </summary>
/// <param name="invocationId">Method invocation identifier.</param>
/// <param name="response">The response instance.</param>
public virtual void ReceiveResponse(string invocationId, HttpResponseMessage response)
{
string responseAsString = response == null ? string.Empty : response.AsFormattedString();
HttpOperationEventSource.Log.ReceiveResponse(invocationId, responseAsString);
}
示例6: ReceiveResponse
/// <summary>
/// Receive an HTTP response.
/// </summary>
/// <param name="invocationId">Method invocation identifier.</param>
/// <param name="response">The response instance.</param>
public void ReceiveResponse(string invocationId, HttpResponseMessage response)
{
string requestAsString = (response == null ? string.Empty : response.AsFormattedString());
_logger.DebugFormat(CultureInfo.InvariantCulture,
"invocationId: {0}\r\nresponse: {1}", invocationId, requestAsString);
}
示例7: HttpResponseMessageAsFormattedStringHandlesRequestsWithContent
public void HttpResponseMessageAsFormattedStringHandlesRequestsWithContent()
{
using (var httpRequest = new HttpResponseMessage(HttpStatusCode.OK))
{
httpRequest.Content = new StringContent("<body/>");
var formattedString = httpRequest.AsFormattedString();
Assert.Contains("StatusCode: 200", formattedString);
Assert.Contains("<body/>", formattedString);
}
}