本文整理匯總了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);
}