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