Пример #1
0
        public void can_write_multiple_values_for_the_same_header()
        {
            response.AppendHeader("X-1", "A");
            response.AppendHeader("X-1", "B");

            var dictionary = environment.Get <IDictionary <string, string[]> >(OwinConstants.ResponseHeadersKey);

            dictionary
            .Get("X-1").ShouldHaveTheSameElementsAs("A", "B");
        }
        public void write_a_header_that_allows_multiple_values()
        {
            var settings = new OwinHeaderSettings();
            var environment = new Dictionary<string, object>
            {
                {OwinConstants.HeaderSettings, settings}
            };
            var response = new OwinHttpResponse(environment);

            response.AppendHeader(HttpGeneralHeaders.Allow, "application/json");
            response.AppendHeader(HttpGeneralHeaders.Allow, "text/json");

            var headers = environment.Get<IDictionary<string, string[]>>(OwinConstants.ResponseHeadersKey);
            headers[HttpGeneralHeaders.Allow].ShouldHaveTheSameElementsAs("application/json", "text/json");
        }
        public Task Invoke(IDictionary<string, object> environment)
        {
            var writer = new OwinHttpResponse(environment);
            writer.AppendHeader("James", "Bond");

            return _inner(environment);
        }
Пример #4
0
        public void write_a_header_that_allows_multiple_values()
        {
            var settings    = new OwinHeaderSettings();
            var environment = new Dictionary <string, object>
            {
                { OwinConstants.HeaderSettings, settings }
            };
            var response = new OwinHttpResponse(environment);

            response.AppendHeader(HttpGeneralHeaders.Allow, "application/json");
            response.AppendHeader(HttpGeneralHeaders.Allow, "text/json");

            var headers = environment.Get <IDictionary <string, string[]> >(OwinConstants.ResponseHeadersKey);

            headers[HttpGeneralHeaders.Allow].ShouldHaveTheSameElementsAs("application/json", "text/json");
        }
Пример #5
0
        public Task Invoke(IDictionary<string, object> environment)
        {
            var path = environment[OwinConstants.RequestPathKey].As<string>().TrimStart('/');

            if (path == "topics.js")
            {
                return Task.Factory.StartNew(() =>
                {
                    var response = new OwinHttpResponse(environment);
                    response.WriteContentType("text/javascript");
                    new AssetSettings().Headers.Each((key, func) => response.AppendHeader(key, func()));
                    response.Write(_topicJS);

                    response.Flush();
                });
            }

            var topic = _project.FindTopicByUrl(path);
            if (topic == null)
            {
                return _inner(environment);
            }

            return Task.Factory.StartNew(() =>
            {
                var response = new OwinHttpResponse(environment);
                response.WriteContentType("text/html");

                var html = GenerateHtml(topic);

                response.Write(html);
                response.Flush();
            });
        }
Пример #6
0
        public Task Invoke(IDictionary<string, object> environment)
        {
            var writer = new OwinHttpResponse(environment);
            writer.AppendHeader("Slow-Moving", "Laser");

            return _inner(environment);
        }
Пример #7
0
        public Task Invoke(IDictionary <string, object> environment)
        {
            var writer = new OwinHttpResponse(environment);

            writer.AppendHeader("James", "Bond");

            return(_inner(environment));
        }
        public void write_a_header_that_does_not_allow_multiple_values()
        {
            var settings = new OwinHeaderSettings();
            var environment = new Dictionary<string, object>
            {
                {OwinConstants.HeaderSettings, settings}
            };
            var response = new OwinHttpResponse(environment);

            settings.DoNotAllowMultipleValues(HttpRequestHeaders.ContentLength);

            response.AppendHeader(HttpRequestHeaders.ContentLength, "1234");
            response.AppendHeader(HttpRequestHeaders.ContentLength, "1234");

            var headers = environment.Get<IDictionary<string, string[]>>(OwinConstants.ResponseHeadersKey);
            headers[HttpRequestHeaders.ContentLength].ShouldHaveTheSameElementsAs("1234");
        }
Пример #9
0
        public Task Invoke(IDictionary <string, object> environment)
        {
            var writer = new OwinHttpResponse(environment);

            writer.AppendHeader("Slow-Moving", "Laser");

            return(_inner(environment));
        }
Пример #10
0
        public void write_a_header_that_does_not_allow_multiple_values()
        {
            var settings    = new OwinHeaderSettings();
            var environment = new Dictionary <string, object>
            {
                { OwinConstants.HeaderSettings, settings }
            };
            var response = new OwinHttpResponse(environment);

            settings.DoNotAllowMultipleValues(HttpRequestHeaders.ContentLength);

            response.AppendHeader(HttpRequestHeaders.ContentLength, "1234");
            response.AppendHeader(HttpRequestHeaders.ContentLength, "1234");

            var headers = environment.Get <IDictionary <string, string[]> >(OwinConstants.ResponseHeadersKey);

            headers[HttpRequestHeaders.ContentLength].ShouldHaveTheSameElementsAs("1234");
        }
Пример #11
0
        public Task Invoke(IDictionary<string, object> environment)
        {
            var path = environment[OwinConstants.RequestPathKey].As<string>().TrimStart('/');

            if (path == "topics.js")
            {
                return Task.Factory.StartNew(() =>
                {
                    var response = new OwinHttpResponse(environment);
                    response.WriteContentType("text/javascript");

                    response.Write(_topicJS);


                   
                    response.Flush();
                });
            }

            var topic = _project.FindTopicByUrl(path);
            if (topic == null)
            {
                return _inner(environment);
            }

            return Task.Factory.StartNew(() =>
            {
                var response = new OwinHttpResponse(environment);
                response.WriteContentType("text/html");

                response.AppendHeader(HttpGeneralHeaders.CacheControl, "no-cache, no-store, must-revalidate");
                response.AppendHeader(HttpResponseHeaders.Pragma, "no-cache");
                response.AppendHeader(HttpResponseHeaders.Expires, "0");


                var html = GenerateHtml(topic);


                response.Write(html);
                response.Flush();
            });

        }
Пример #12
0
        public Task Invoke(IDictionary <string, object> environment)
        {
            var path = environment[OwinConstants.RequestPathKey].As <string>().TrimStart('/');

            if (path == "topics.js")
            {
                return(Task.Factory.StartNew(() =>
                {
                    var response = new OwinHttpResponse(environment);
                    response.WriteContentType("text/javascript");

                    response.Write(_topicJS);



                    response.Flush();
                }));
            }

            var topic = _project.FindTopicByUrl(path);

            if (topic == null)
            {
                return(_inner(environment));
            }

            return(Task.Factory.StartNew(() =>
            {
                var response = new OwinHttpResponse(environment);
                response.WriteContentType("text/html");

                response.AppendHeader(HttpGeneralHeaders.CacheControl, "no-cache, no-store, must-revalidate");
                response.AppendHeader(HttpResponseHeaders.Pragma, "no-cache");
                response.AppendHeader(HttpResponseHeaders.Expires, "0");


                var html = GenerateHtml(topic);


                response.Write(html);
                response.Flush();
            }));
        }
Пример #13
0
        public Task Invoke(IDictionary <string, object> environment)
        {
            var path = environment[OwinConstants.RequestPathKey].As <string>().TrimStart('/');

            if (path == "topics.js")
            {
                return(Task.Factory.StartNew(() =>
                {
                    var response = new OwinHttpResponse(environment);
                    response.WriteContentType("text/javascript");
                    new AssetSettings().Headers.Each((key, func) => response.AppendHeader(key, func()));
                    response.Write(_topicJS);

                    response.Flush();
                }));
            }

            var topic = _project.FindTopicByUrl(path);

            if (topic == null)
            {
                return(_inner(environment));
            }

            return(Task.Factory.StartNew(() =>
            {
                var response = new OwinHttpResponse(environment);
                response.WriteContentType("text/html");

                var html = GenerateHtml(topic);


                response.Write(html);
                response.Flush();
            }));
        }