当前位置: 首页>>代码示例>>C#>>正文


C# HttpResponseMessage.AsFormattedString方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:8,代码来源:CloudTracingExtensionsTest.cs

示例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);
     }
 }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:10,代码来源:CloudTracingExtensionsTest.cs

示例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);
 }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:11,代码来源:Log4NetTracingInterceptorTest.cs

示例4: ReceiveResponse

 public void ReceiveResponse(string invocationId, HttpResponseMessage response)
 {
     _logger.LogInformation("   response: {0}", response.AsFormattedString());
 }
开发者ID:jhancock93,项目名称:autorest,代码行数:4,代码来源:TestTracingInterceptor.cs

示例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);
        }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:11,代码来源:EtwTracingInterceptor.cs

示例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);
 }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:11,代码来源:Log4NetTracingInterceptor.cs

示例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);
     }
 }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:10,代码来源:CloudTracingExtensionsTest.cs


注:本文中的System.Net.Http.HttpResponseMessage.AsFormattedString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。