當前位置: 首頁>>代碼示例>>C#>>正文


C# HttpRequestMessage.AsFormattedString方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:Ranjana1996,項目名稱:autorest,代碼行數:8,代碼來源:CloudTracingExtensionsTest.cs

示例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);
 }
開發者ID:Ranjana1996,項目名稱:autorest,代碼行數:11,代碼來源:Log4NetTracingInterceptorTest.cs

示例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);
     }
 }
開發者ID:Ranjana1996,項目名稱:autorest,代碼行數:11,代碼來源:CloudTracingExtensionsTest.cs

示例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);
     }
 }
開發者ID:Ranjana1996,項目名稱:autorest,代碼行數:11,代碼來源:CloudTracingExtensionsTest.cs

示例5: SendRequest

 public void SendRequest(string invocationId, HttpRequestMessage request)
 {
     _logger.LogInformation("    request: {0}", request.AsFormattedString());
 }
開發者ID:jhancock93,項目名稱:autorest,代碼行數:4,代碼來源:TestTracingInterceptor.cs

示例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);
        }
開發者ID:Ranjana1996,項目名稱:autorest,代碼行數:11,代碼來源:EtwTracingInterceptor.cs

示例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);
 }
開發者ID:Ranjana1996,項目名稱:autorest,代碼行數:11,代碼來源:Log4NetTracingInterceptor.cs

示例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);
 }
開發者ID:ApplicationGateway,項目名稱:azure-sdk-for-net,代碼行數:10,代碼來源:Log4NetTracingInterceptor.cs


注:本文中的System.Net.Http.HttpRequestMessage.AsFormattedString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。