{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/Diagnostics/pulls/comments/23899263","id":23899263,"diff_hunk":"@@ -0,0 +1,44 @@\n+﻿// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.\n+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\n+\n+using System;\n+using System.Threading.Tasks;\n+using Microsoft.AspNet.Builder;\n+using Microsoft.AspNet.Http;\n+\n+namespace Microsoft.AspNet.Diagnostics\n+{\n+    public class StatusCodePagesMiddleware\n+    {\n+        private readonly RequestDelegate _next;\n+        private readonly StatusCodePagesOptions _options;\n+\n+        public StatusCodePagesMiddleware(RequestDelegate next, StatusCodePagesOptions options)\n+        {\n+            _next = next;\n+            _options = options;\n+            if (_options.HandleAsync == null)\n+            {\n+                throw new ArgumentException(\"Missing HandleAsync implementation.\");\n+            }\n+        }\n+\n+        public async Task Invoke(HttpContext context)\n+        {\n+            await _next(context);\n+\n+            // Do nothing if a response body has already been provided.\n+            if (context.Response.HeadersSent\n+                || context.Response.StatusCode < 400\n+                || context.Response.StatusCode >= 600\n+                || context.Response.ContentLength.HasValue\n+                || !string.IsNullOrEmpty(context.Response.ContentType))","path":"src/Microsoft.AspNet.Diagnostics/StatusCodePagesMiddleware.cs","position":35,"original_position":35,"commit_id":"7e5dc0a66f47ee490d785fdbcbc521f94ea3cfcc","original_commit_id":"7e5dc0a66f47ee490d785fdbcbc521f94ea3cfcc","user":{"login":"yishaigalatzer","id":1238711,"avatar_url":"https://avatars.githubusercontent.com/u/1238711?v=3","gravatar_id":"","url":"https://api.github.com/users/yishaigalatzer","html_url":"https://github.com/yishaigalatzer","followers_url":"https://api.github.com/users/yishaigalatzer/followers","following_url":"https://api.github.com/users/yishaigalatzer/following{/other_user}","gists_url":"https://api.github.com/users/yishaigalatzer/gists{/gist_id}","starred_url":"https://api.github.com/users/yishaigalatzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yishaigalatzer/subscriptions","organizations_url":"https://api.github.com/users/yishaigalatzer/orgs","repos_url":"https://api.github.com/users/yishaigalatzer/repos","events_url":"https://api.github.com/users/yishaigalatzer/events{/privacy}","received_events_url":"https://api.github.com/users/yishaigalatzer/received_events","type":"User","site_admin":false},"body":"Where is the handling for a buffered stream that was written to by downstream component.\r\n\r\ne.g. MVC Set an HTML page with 404 - in this case response headers didn't go out, and something is in the stream already","created_at":"2015-02-01T17:38:02Z","updated_at":"2015-02-01T17:38:02Z","html_url":"https://github.com/aspnet/Diagnostics/pull/83#discussion_r23899263","pull_request_url":"https://api.github.com/repos/aspnet/Diagnostics/pulls/83","_links":{"self":{"href":"https://api.github.com/repos/aspnet/Diagnostics/pulls/comments/23899263"},"html":{"href":"https://github.com/aspnet/Diagnostics/pull/83#discussion_r23899263"},"pull_request":{"href":"https://api.github.com/repos/aspnet/Diagnostics/pulls/83"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/Diagnostics/pulls/83","id":28135031,"html_url":"https://github.com/aspnet/Diagnostics/pull/83","diff_url":"https://github.com/aspnet/Diagnostics/pull/83.diff","patch_url":"https://github.com/aspnet/Diagnostics/pull/83.patch","issue_url":"https://api.github.com/repos/aspnet/Diagnostics/issues/83","number":83,"state":"open","locked":false,"title":"StatusCodePages middleware","user":{"login":"Tratcher","id":1821173,"avatar_url":"https://avatars.githubusercontent.com/u/1821173?v=3","gravatar_id":"","url":"https://api.github.com/users/Tratcher","html_url":"https://github.com/Tratcher","followers_url":"https://api.github.com/users/Tratcher/followers","following_url":"https://api.github.com/users/Tratcher/following{/other_user}","gists_url":"https://api.github.com/users/Tratcher/gists{/gist_id}","starred_url":"https://api.github.com/users/Tratcher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tratcher/subscriptions","organizations_url":"https://api.github.com/users/Tratcher/orgs","repos_url":"https://api.github.com/users/Tratcher/repos","events_url":"https://api.github.com/users/Tratcher/events{/privacy}","received_events_url":"https://api.github.com/users/Tratcher/received_events","type":"User","site_admin":false},"body":"#66\r\n\r\nSubmitting for design feedback, it's not ready for a detailed code review yet. Are the handlers provided useful (response, redirect, tangent, re-execute)?\r\n\r\nEntropy MVC sample: https://github.com/aspnet/Entropy/pull/38\r\n\r\nRe-execute works OK with MVC. Static files would only work well with the redirect scenario due to all the request and response headers it uses, and the fact that it overwrites the status code. However you could do a simpler version of static files by going directly to the WebRootFileProvider and serving the content yourself.\r\n\r\n@loudej @davidfowl @GrabYourPitchforks @yishaigalatzer ","created_at":"2015-01-27T19:03:18Z","updated_at":"2015-02-01T17:38:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d7e79d939b1c0f028745bcea8b8e9c2851f77caf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/Diagnostics/pulls/83/commits","review_comments_url":"https://api.github.com/repos/aspnet/Diagnostics/pulls/83/comments","review_comment_url":"https://api.github.com/repos/aspnet/Diagnostics/pulls/comments/{number}","comments_url":"https://api.github.com/repos/aspnet/Diagnostics/issues/83/comments","statuses_url":"https://api.github.com/repos/aspnet/Diagnostics/statuses/7e5dc0a66f47ee490d785fdbcbc521f94ea3cfcc","head":{"label":"aspnet:statuscode","ref":"statuscode","sha":"7e5dc0a66f47ee490d785fdbcbc521f94ea3cfcc","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":17548048,"name":"Diagnostics","full_name":"aspnet/Diagnostics","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Diagnostics","description":"Middleware to show diagnostic information about a site, including error pages.","fork":false,"url":"https://api.github.com/repos/aspnet/Diagnostics","forks_url":"https://api.github.com/repos/aspnet/Diagnostics/forks","keys_url":"https://api.github.com/repos/aspnet/Diagnostics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Diagnostics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Diagnostics/teams","hooks_url":"https://api.github.com/repos/aspnet/Diagnostics/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Diagnostics/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Diagnostics/events","assignees_url":"https://api.github.com/repos/aspnet/Diagnostics/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Diagnostics/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Diagnostics/tags","blobs_url":"https://api.github.com/repos/aspnet/Diagnostics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Diagnostics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Diagnostics/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Diagnostics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Diagnostics/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Diagnostics/languages","stargazers_url":"https://api.github.com/repos/aspnet/Diagnostics/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Diagnostics/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Diagnostics/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Diagnostics/subscription","commits_url":"https://api.github.com/repos/aspnet/Diagnostics/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Diagnostics/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Diagnostics/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Diagnostics/issues/comments/{number}","contents_url":"https://api.github.com/repos/aspnet/Diagnostics/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Diagnostics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Diagnostics/merges","archive_url":"https://api.github.com/repos/aspnet/Diagnostics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Diagnostics/downloads","issues_url":"https://api.github.com/repos/aspnet/Diagnostics/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Diagnostics/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Diagnostics/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Diagnostics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Diagnostics/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Diagnostics/releases{/id}","created_at":"2014-03-08T18:25:57Z","updated_at":"2015-01-30T09:47:50Z","pushed_at":"2015-01-29T02:00:42Z","git_url":"git://github.com/aspnet/Diagnostics.git","ssh_url":"git@github.com:aspnet/Diagnostics.git","clone_url":"https://github.com/aspnet/Diagnostics.git","svn_url":"https://github.com/aspnet/Diagnostics","homepage":"","size":1722,"stargazers_count":29,"watchers_count":29,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":34,"forks":14,"open_issues":34,"watchers":29,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"f015f3c0b3ebcc25f44624d386778673f2e448a1","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":17548048,"name":"Diagnostics","full_name":"aspnet/Diagnostics","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Diagnostics","description":"Middleware to show diagnostic information about a site, including error pages.","fork":false,"url":"https://api.github.com/repos/aspnet/Diagnostics","forks_url":"https://api.github.com/repos/aspnet/Diagnostics/forks","keys_url":"https://api.github.com/repos/aspnet/Diagnostics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Diagnostics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Diagnostics/teams","hooks_url":"https://api.github.com/repos/aspnet/Diagnostics/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Diagnostics/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Diagnostics/events","assignees_url":"https://api.github.com/repos/aspnet/Diagnostics/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Diagnostics/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Diagnostics/tags","blobs_url":"https://api.github.com/repos/aspnet/Diagnostics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Diagnostics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Diagnostics/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Diagnostics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Diagnostics/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Diagnostics/languages","stargazers_url":"https://api.github.com/repos/aspnet/Diagnostics/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Diagnostics/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Diagnostics/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Diagnostics/subscription","commits_url":"https://api.github.com/repos/aspnet/Diagnostics/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Diagnostics/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Diagnostics/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Diagnostics/issues/comments/{number}","contents_url":"https://api.github.com/repos/aspnet/Diagnostics/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Diagnostics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Diagnostics/merges","archive_url":"https://api.github.com/repos/aspnet/Diagnostics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Diagnostics/downloads","issues_url":"https://api.github.com/repos/aspnet/Diagnostics/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Diagnostics/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Diagnostics/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Diagnostics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Diagnostics/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Diagnostics/releases{/id}","created_at":"2014-03-08T18:25:57Z","updated_at":"2015-01-30T09:47:50Z","pushed_at":"2015-01-29T02:00:42Z","git_url":"git://github.com/aspnet/Diagnostics.git","ssh_url":"git@github.com:aspnet/Diagnostics.git","clone_url":"https://github.com/aspnet/Diagnostics.git","svn_url":"https://github.com/aspnet/Diagnostics","homepage":"","size":1722,"stargazers_count":29,"watchers_count":29,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":34,"forks":14,"open_issues":34,"watchers":29,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/Diagnostics/pulls/83"},"html":{"href":"https://github.com/aspnet/Diagnostics/pull/83"},"issue":{"href":"https://api.github.com/repos/aspnet/Diagnostics/issues/83"},"comments":{"href":"https://api.github.com/repos/aspnet/Diagnostics/issues/83/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/Diagnostics/pulls/83/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/Diagnostics/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/aspnet/Diagnostics/pulls/83/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/Diagnostics/statuses/7e5dc0a66f47ee490d785fdbcbc521f94ea3cfcc"}}}}