• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Http.HttpResponseMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Http.HttpResponseMessage的典型用法代码示例。如果您正苦于以下问题:C# HttpResponseMessage类的具体用法?C# HttpResponseMessage怎么用?C# HttpResponseMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpResponseMessage类属于Microsoft.Http命名空间,在下文中一共展示了HttpResponseMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: NewRestfulieProxy

 private RestfulieProxy NewRestfulieProxy(HttpResponseMessage httpResponseMessage)
 {
     return new RestfulieProxy(_httpClient, _dynamicContentParserFactory, _httpMethodDiscoverer)
     {
         LatestHttpResponseMessage = httpResponseMessage,
         DynamicContentParser = _dynamicContentParserFactory.New(httpResponseMessage.Content)
     };
 }
开发者ID:sharpshooting,项目名称:restfulie-csharp,代码行数:8,代码来源:Restfulie.cs


示例2: ProcessRequestAndTryGetResponse

            protected override void ProcessRequestAndTryGetResponse(HttpRequestMessage request, out HttpResponseMessage response, out object state)
            {
                response = _httpResponseMessage;

                response.Request = request;
                response.Method = request.Method;

                state = _state;
            }
开发者ID:sharpshooting,项目名称:restfulie-csharp,代码行数:9,代码来源:HttpClientFake.cs


示例3: LogResponse

 public static void LogResponse(this IDnaLogger logger,HttpStatusCode httpStatusCode, HttpResponseMessage httpResponse)
 {
     var props = new Dictionary<string, object>() 
     { 
         { "Result", httpStatusCode.ToString()},
         { "Uri", httpResponse.Uri.ToString()},
         { "Content", httpResponse.Content.ReadAsString()}
     };
     string category = Assembly.GetCallingAssembly().GetName().Name + ".Responses";
     logger.LogGeneral(TraceEventType.Information, category, "", DateTime.MaxValue, props);
 }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:11,代码来源:LogUtility.cs


示例4: SetUp

        public void SetUp()
        {
            MockedHttpClientAdapter = new Mock<IHttpClientAdapter>();
            MockedHttpClient = new Mock<IHttpClient>();
            MockedConfigSettings = new Mock<IConfigSettings>();

            PackageAuthenticator = new Infrastructure.Impl.PackageAuthenticator(MockedHttpClientAdapter.Object, MockedConfigSettings.Object,
                new Mock<ILogger>().Object);

            OkHttpResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = HttpContent.Create("true") };
        }
开发者ID:dioptre,项目名称:nkd,代码行数:11,代码来源:PackageTesterBase.cs


示例5: ShouldProvideHttpStatusCodeUponRecievingResponse

        public void ShouldProvideHttpStatusCodeUponRecievingResponse()
        {
            var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK };

            dynamic resource = new RestfulieProxy(It.IsAny<IHttpClient>(), It.IsAny<IDynamicContentParserFactory>(), It.IsAny<IHttpMethodDiscoverer>())
            {
                LatestHttpResponseMessage = httpResponseMessage
            };

            Assert.AreEqual("200", resource.StatusCode);
        }
开发者ID:sharpshooting,项目名称:restfulie-csharp,代码行数:11,代码来源:RestfulieProxyTests.cs


示例6: FaultFor

 private static Fault FaultFor(HttpResponseMessage response)
 {
     Fault fault;
     try
     {
         fault = response.Content.ReadAsDataContract<Fault>();
     }
     catch (Exception)
     {
         fault = new Fault() {Message = response.StatusCode.ToString()};
     }
     return fault;
 }
开发者ID:RaoulHolzer,项目名称:EnergyTrading-MDM-Sample,代码行数:13,代码来源:HttpResponseExtensions.cs


示例7: ToNativeResponse

 private static DataPackets.HttpResponseMessage ToNativeResponse(HttpResponseMessage response)
 {
     var responseFormat = new DataPackets.HttpResponseMessage
     {
         Content =
         {
             Content = Zip.GetUnzippedContent(response),
             ContentType = response.Content.ContentType,
             Encoding = GetEncoding(response.Content.ContentType)
         },
         Method = response.Method,
         Properties = response.Properties,
         StatusCode = response.StatusCode,
         Uri = response.Uri
     };
     return responseFormat;
 }
开发者ID:RJacksonm1,项目名称:JustGiving.Api.Sdk,代码行数:17,代码来源:HttpClientWrapper.cs


示例8: AssertHttpResponse

        public static void AssertHttpResponse(HttpResponseMessage response,string methodName)
        {
            bool succeed = false;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                succeed = true;
                TextLog.LogMessage(methodName + ": Test Case Pass.");
                Console.WriteLine(methodName + ": Get Response successfully.");
            }
            else
            {
                succeed = false;
                TextLog.LogMessage(methodName + ": Test Case Pass.");
                Console.WriteLine(methodName + ": Get Response failed.");
            }

            Assert.AreEqual(true, succeed);
        }
开发者ID:barbarossia,项目名称:DIS,代码行数:19,代码来源:Verification.cs


示例9: InvokeHandler

 bool InvokeHandler(HttpResponseMessage response)
 {
     ConditionalGetEventArgs args = new ConditionalGetEventArgs() { Response = response };
     return InvokeHandler(args);
 }
开发者ID:pusp,项目名称:o2platform,代码行数:5,代码来源:PollingAgent.cs


示例10: ShouldThrowWhenGivenResponseReturnedBadRequest

        public void ShouldThrowWhenGivenResponseReturnedBadRequest()
        {
            var response = new HttpResponseMessage {StatusCode = HttpStatusCode.BadRequest};
            MockedHttpClientAdapter.Setup(hca => hca.GetHttpClient(It.IsAny<string>())).Returns(MockedHttpClient.Object);
            MockedHttpClient.Setup(hc => hc.Get(It.IsAny<string>())).Returns(response);

            TestDelegate methodThatShouldThrow = () => PackageAuthenticator.EnsureKeyCanAccessPackage("key", "packageId", "packageVersion");

            Assert.Throws<Exception>(methodThatShouldThrow, "Should have thrown when reponse returned not-OK status code.");
        }
开发者ID:dioptre,项目名称:nkd,代码行数:10,代码来源:EnsureKeyCanAccessPackageTester.cs


示例11: LoadFeed

 private static SyndicationFeed LoadFeed(HttpResponseMessage message)
 {
     XmlReader reader = XmlReader.Create(
         message.Content.ReadAsStream(), new XmlReaderSettings { ProhibitDtd = false });
     SyndicationFeed feed = SyndicationFeed.Load(reader);
     return feed;
 }
开发者ID:RaoulHolzer,项目名称:EnergyTrading-MDM-Sample,代码行数:7,代码来源:success_search_results_paged.cs


示例12: Because_of

        protected static void Because_of()
        {
            client.DefaultHeaders.Add("If-Match", entity.Version.ToString(System.Globalization.CultureInfo.InvariantCulture));

            response = client.Post(ServiceUrl["Person"] +  string.Format("{0}/Mapping/{1}", entity.Id,
                int.MaxValue), content);
        }
开发者ID:RaoulHolzer,项目名称:EnergyTrading-MDM-Sample,代码行数:7,代码来源:xml_data_invalid.cs


示例13: Because_of

        protected static void Because_of()
        {
            client.DefaultHeaders.Add("If-Match", long.MaxValue.ToString());

            response = client.Post(ServiceUrl["Person"] +  string.Format("{0}/Mapping/{1}", entity.Id,
                entity.Mappings[0].Id), content);
        }
开发者ID:RaoulHolzer,项目名称:EnergyTrading-MDM-Sample,代码行数:7,代码来源:version_conflict.cs


示例14: Because_of

        protected static void Because_of()
        {
            client.DefaultHeaders.Add("If-Match", entity.Mappings[0].Version.ToUnsignedLongVersion().ToString());

            response = client.Post(ServiceUrl["LegalEntity"] +  string.Format("{0}/Mapping/{1}", entity.Id,
                int.MaxValue), content);
        }
开发者ID:RaoulHolzer,项目名称:EnergyTrading-MDM-Sample,代码行数:7,代码来源:xml_data_invalid.cs


示例15: Because_of

        protected static void Because_of()
        {
            client = new HttpClient(ServiceUrl["Counterparty"] +
                "crossmap?source-system=trayport&destination-system=endur&mapping-string=abc");

            response = client.Get();
        }
开发者ID:RaoulHolzer,项目名称:EnergyTrading-MDM-Sample,代码行数:7,代码来源:source_system_mapping_unkown.cs


示例16: Because_of

        protected static void Because_of()
        {
            var entity = CurveData.CreateBasicEntityWithOneMapping();

            client = new HttpClient(ServiceUrl["Curve"] + string.Format("{0}/mapping/{1}", entity.Id, int.MaxValue));

            response = client.Get();
        }
开发者ID:RaoulHolzer,项目名称:EnergyTrading-MDM-Sample,代码行数:8,代码来源:mapping_not_found.cs


示例17: Because_of

        protected static void Because_of()
        {
            client = new HttpClient(ServiceUrl["Exchange"] +
                    "map?source-system=Trayport&mapping-string=" + exchange.Mappings[0].MappingValue + "&as-of=" +
                    exchange.Validity.Start.ToString(DateFormatString));

            response = client.Get();
        }
开发者ID:RaoulHolzer,项目名称:EnergyTrading-MDM-Sample,代码行数:8,代码来源:successful.cs


示例18: Because_of

        protected static void Because_of()
        {
            client = new HttpClient(ServiceUrl["Location"] +
                "crossmap?source-system=" + trayport.Name + "&destination-system=" + endur.Name + "&mapping-string=" + trayportMapping.MappingValue);

            response = client.Get();

            mappingResponse = response.Content.ReadAsDataContract<EnergyTrading.Mdm.Contracts.Fault>();
        }
开发者ID:RaoulHolzer,项目名称:EnergyTrading-MDM-Sample,代码行数:9,代码来源:fails_with_no_default_and_multiple_mappings.cs


示例19: Because_of

        protected static void Because_of()
        {
            entity = BrokerData.CreateBasicEntityWithOneMapping();
            mapping = entity.Mappings[0];
            client = new HttpClient(ServiceUrl["Broker"] + string.Format("{0}/mapping/{1}", entity.Id, mapping.Id));

            response = client.Get();
            mappingResponse = response.Content.ReadAsDataContract<EnergyTrading.Mdm.Contracts.MappingResponse>();
        }
开发者ID:RaoulHolzer,项目名称:EnergyTrading-MDM-Sample,代码行数:9,代码来源:successful.cs


示例20: Because_of

        protected static void Because_of()
        {
            pageOneResponse = client.Post(ServiceUrl["Broker"] + "search", content);
            var feed1 = LoadFeed(pageOneResponse);
            pageOne = GetPeopleFromFeed(feed1);
            pageOneNextPage = GetNextPageFromFeed(feed1);

            pageTwoResponse = client.Get(pageOneNextPage);
            var feed2 = LoadFeed(pageTwoResponse);
            pageTwo = GetPeopleFromFeed(feed2);
            pageTwoNextPage = GetNextPageFromFeed(feed2);
        }
开发者ID:RaoulHolzer,项目名称:EnergyTrading-MDM-Sample,代码行数:12,代码来源:success_search_results_paged.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ActiveDirectory.AuthenticationContext类代码示例发布时间:2022-05-26
下一篇:
C# Http.HttpContent类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap