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


C# HttpEntityManager.Reply方法代码示例

本文整理汇总了C#中EventStore.Transport.Http.EntityManagement.HttpEntityManager.Reply方法的典型用法代码示例。如果您正苦于以下问题:C# HttpEntityManager.Reply方法的具体用法?C# HttpEntityManager.Reply怎么用?C# HttpEntityManager.Reply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventStore.Transport.Http.EntityManagement.HttpEntityManager的用法示例。


在下文中一共展示了HttpEntityManager.Reply方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestAnonymousHandler

 private void TestAnonymousHandler(HttpEntityManager http, UriTemplateMatch match)
 {
     if (http.User != null)
         http.Reply("ERROR", 500, "ERROR", "text/plain");
     else 
         http.Reply("OK", 200, "OK", "text/plain");
 }
开发者ID:kijanawoodard,项目名称:EventStore,代码行数:7,代码来源:TestController.cs

示例2: Test1Handler

 private void Test1Handler(HttpEntityManager http, UriTemplateMatch match)
 {
     if (http.User != null) 
         http.Reply("OK", 200, "OK", "text/plain");
     else 
         http.Reply("Please authenticate yourself", 401, "Unauthorized", "text/plain");
 }
开发者ID:kijanawoodard,项目名称:EventStore,代码行数:7,代码来源:TestController.cs

示例3: TestEncodingHandler

        private void TestEncodingHandler(HttpEntityManager http, UriTemplateMatch match)
        {
            var a = match.BoundVariables["a"];
            var b = match.BoundVariables["b"];

            http.Reply(new { a = a, b = b, rawSegment = http.RequestedUrl.Segments[2] }.ToJson(), 200, "OK", "application/json");
        }
开发者ID:kijanawoodard,项目名称:EventStore,代码行数:7,代码来源:TestController.cs

示例4: OnGetHistogram

 private void OnGetHistogram(HttpEntityManager entity, UriTemplateMatch match)
 {
     var name = match.BoundVariables["name"];
    
     var histogram = Histograms.HistogramService.GetHistogram(name);
     if (histogram == null)
     {
         entity.ReplyStatus(HttpStatusCode.NotFound, "Not found", _ => { });
         return;
     }
     var writer = new StringWriter();
     lock (histogram)
     {
         histogram.outputPercentileDistribution(writer, outputValueUnitScalingRatio: 1000.0*1000.0);
     }
     var response = Encoding.ASCII.GetBytes(writer.ToString());
     entity.Reply(response,
         HttpStatusCode.OK, 
         "OK", 
         ContentType.PlainText, 
         Encoding.ASCII, 
         null,
         _ => { });
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:24,代码来源:HistogramController.cs

示例5: ReplyWithContent

        private void ReplyWithContent(HttpEntityManager http, string contentLocalPath)
        {
            //NOTE: this is fix for Mono incompatibility in UriTemplate behavior for /a/b{*C}
            if (("/" + contentLocalPath).StartsWith(_localWebRootPath))
                contentLocalPath = contentLocalPath.Substring(_localWebRootPath.Length);

            //_logger.Trace("{0} requested from MiniWeb", contentLocalPath);
            try
            {
                var extensionToContentType = new Dictionary<string, string>
                {
                    { ".png",  "image/png"} ,
                    { ".jpg",  "image/jpeg"} ,
                    { ".jpeg", "image/jpeg"} ,
                    { ".css",  "text/css"} ,
                    { ".htm",  "text/html"} ,
                    { ".html", "text/html"} ,
                    { ".js",   "application/javascript"} ,
                    { ".json",   "application/json"} ,
                    { ".ico",  "image/vnd.microsoft.icon"}
                };

                var extension = Path.GetExtension(contentLocalPath);
                var fullPath = Path.Combine(_fileSystemRoot, contentLocalPath);

                string contentType;
                if (string.IsNullOrEmpty(extension)
                    || !extensionToContentType.TryGetValue(extension.ToLower(), out contentType)
                    || !File.Exists(fullPath))
                {
                    _logger.Info("Replying 404 for {0} ==> {1}", contentLocalPath, fullPath);
                    http.ReplyTextContent(
                        "Not Found", 404, "Not Found", "text/plain", null, 
                        ex => _logger.InfoException(ex, "Error while replying from MiniWeb"));
                }
                else
                {
                    var config = GetWebPageConfig(contentType);
                    var content = File.ReadAllBytes(fullPath);

                    http.Reply(content,
                                       config.Code,
                                       config.Description,
                                       config.ContentType,
                                       config.Encoding,
                                       config.Headers,
                                       ex => _logger.InfoException(ex, "Error while replying from MiniWeb"));
                }
            }
            catch (Exception ex)
            {
                http.ReplyTextContent(ex.ToString(), 500, "Internal Server Error", "text/plain", null, Console.WriteLine);
            }
        }
开发者ID:MariuszTrybus,项目名称:EventStore,代码行数:54,代码来源:MiniWeb.cs

示例6: TestTimeoutHandler

 private void TestTimeoutHandler(HttpEntityManager http, UriTemplateMatch match) 
 {
     var sleepFor = int.Parse(match.BoundVariables["sleepfor"]);
     System.Threading.Thread.Sleep(sleepFor);
     http.Reply("OK", 200, "OK", "text/plain");
 }
开发者ID:SzymonPobiega,项目名称:EventStore,代码行数:6,代码来源:TestController.cs


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