{"action":"created","comment":{"url":"https://api.github.com/repos/koajs/cors/pulls/comments/56448815","id":56448815,"diff_hunk":"@@ -70,54 +73,76 @@ module.exports = function (options) {\n       origin = options.origin || requestOrigin;\n     }\n \n+    var headersSet = {};\n+\n+    function set(self, key, value) {\n+      self.set(key, value);\n+      headersSet[key] = value;\n+    }\n+\n     if (this.method !== 'OPTIONS') {\n       // Simple Cross-Origin Request, Actual Request, and Redirects\n \n-      this.set('Access-Control-Allow-Origin', origin);\n+      set(this, 'Access-Control-Allow-Origin', origin);\n \n       if (options.credentials === true) {\n-        this.set('Access-Control-Allow-Credentials', 'true');\n+        set(this, 'Access-Control-Allow-Credentials', 'true');\n       }\n \n       if (options.exposeHeaders) {\n-        this.set('Access-Control-Expose-Headers', options.exposeHeaders);\n+        set(this, 'Access-Control-Expose-Headers', options.exposeHeaders);\n       }\n-\n-      yield next;\n     } else {\n       // Preflight Request\n \n       // If there is no Access-Control-Request-Method header or if parsing failed,\n       // do not set any additional headers and terminate this set of steps.\n       // The request is outside the scope of this specification.\n-      if (!this.get('Access-Control-Request-Method')) {","path":"index.js","position":51,"original_position":51,"commit_id":"26afb4e5c74e270f9498b1c295e7e5705dc33f79","original_commit_id":"26afb4e5c74e270f9498b1c295e7e5705dc33f79","user":{"login":"fengmk2","id":156269,"avatar_url":"https://avatars.githubusercontent.com/u/156269?v=3","gravatar_id":"","url":"https://api.github.com/users/fengmk2","html_url":"https://github.com/fengmk2","followers_url":"https://api.github.com/users/fengmk2/followers","following_url":"https://api.github.com/users/fengmk2/following{/other_user}","gists_url":"https://api.github.com/users/fengmk2/gists{/gist_id}","starred_url":"https://api.github.com/users/fengmk2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fengmk2/subscriptions","organizations_url":"https://api.github.com/users/fengmk2/orgs","repos_url":"https://api.github.com/users/fengmk2/repos","events_url":"https://api.github.com/users/fengmk2/events{/privacy}","received_events_url":"https://api.github.com/users/fengmk2/received_events","type":"User","site_admin":false},"body":"on `Preflight Request`, there is won't throw any error on old code logic https://github.com/koajs/cors/blob/master/index.js#L88.","created_at":"2016-03-17T02:47:12Z","updated_at":"2016-03-17T02:47:12Z","html_url":"https://github.com/koajs/cors/pull/11#discussion_r56448815","pull_request_url":"https://api.github.com/repos/koajs/cors/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/koajs/cors/pulls/comments/56448815"},"html":{"href":"https://github.com/koajs/cors/pull/11#discussion_r56448815"},"pull_request":{"href":"https://api.github.com/repos/koajs/cors/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/koajs/cors/pulls/11","id":62984993,"html_url":"https://github.com/koajs/cors/pull/11","diff_url":"https://github.com/koajs/cors/pull/11.diff","patch_url":"https://github.com/koajs/cors/pull/11.patch","issue_url":"https://api.github.com/repos/koajs/cors/issues/11","number":11,"state":"open","locked":false,"title":"Keep headers after an error","user":{"login":"PlasmaPower","id":6006498,"avatar_url":"https://avatars.githubusercontent.com/u/6006498?v=3","gravatar_id":"","url":"https://api.github.com/users/PlasmaPower","html_url":"https://github.com/PlasmaPower","followers_url":"https://api.github.com/users/PlasmaPower/followers","following_url":"https://api.github.com/users/PlasmaPower/following{/other_user}","gists_url":"https://api.github.com/users/PlasmaPower/gists{/gist_id}","starred_url":"https://api.github.com/users/PlasmaPower/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PlasmaPower/subscriptions","organizations_url":"https://api.github.com/users/PlasmaPower/orgs","repos_url":"https://api.github.com/users/PlasmaPower/repos","events_url":"https://api.github.com/users/PlasmaPower/events{/privacy}","received_events_url":"https://api.github.com/users/PlasmaPower/received_events","type":"User","site_admin":false},"body":"The diff is a bit messy because I had to change a bit of indentation. If this is merged I'll rewrite it for v2.x.","created_at":"2016-03-15T22:06:49Z","updated_at":"2016-03-17T02:47:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"316775d8bee391f96929e18f6168c0dd640a9b6c","assignee":{"login":"fengmk2","id":156269,"avatar_url":"https://avatars.githubusercontent.com/u/156269?v=3","gravatar_id":"","url":"https://api.github.com/users/fengmk2","html_url":"https://github.com/fengmk2","followers_url":"https://api.github.com/users/fengmk2/followers","following_url":"https://api.github.com/users/fengmk2/following{/other_user}","gists_url":"https://api.github.com/users/fengmk2/gists{/gist_id}","starred_url":"https://api.github.com/users/fengmk2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fengmk2/subscriptions","organizations_url":"https://api.github.com/users/fengmk2/orgs","repos_url":"https://api.github.com/users/fengmk2/repos","events_url":"https://api.github.com/users/fengmk2/events{/privacy}","received_events_url":"https://api.github.com/users/fengmk2/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/koajs/cors/pulls/11/commits","review_comments_url":"https://api.github.com/repos/koajs/cors/pulls/11/comments","review_comment_url":"https://api.github.com/repos/koajs/cors/pulls/comments{/number}","comments_url":"https://api.github.com/repos/koajs/cors/issues/11/comments","statuses_url":"https://api.github.com/repos/koajs/cors/statuses/26afb4e5c74e270f9498b1c295e7e5705dc33f79","head":{"label":"PlasmaPower:error-headers","ref":"error-headers","sha":"26afb4e5c74e270f9498b1c295e7e5705dc33f79","user":{"login":"PlasmaPower","id":6006498,"avatar_url":"https://avatars.githubusercontent.com/u/6006498?v=3","gravatar_id":"","url":"https://api.github.com/users/PlasmaPower","html_url":"https://github.com/PlasmaPower","followers_url":"https://api.github.com/users/PlasmaPower/followers","following_url":"https://api.github.com/users/PlasmaPower/following{/other_user}","gists_url":"https://api.github.com/users/PlasmaPower/gists{/gist_id}","starred_url":"https://api.github.com/users/PlasmaPower/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PlasmaPower/subscriptions","organizations_url":"https://api.github.com/users/PlasmaPower/orgs","repos_url":"https://api.github.com/users/PlasmaPower/repos","events_url":"https://api.github.com/users/PlasmaPower/events{/privacy}","received_events_url":"https://api.github.com/users/PlasmaPower/received_events","type":"User","site_admin":false},"repo":{"id":53979866,"name":"cors","full_name":"PlasmaPower/cors","owner":{"login":"PlasmaPower","id":6006498,"avatar_url":"https://avatars.githubusercontent.com/u/6006498?v=3","gravatar_id":"","url":"https://api.github.com/users/PlasmaPower","html_url":"https://github.com/PlasmaPower","followers_url":"https://api.github.com/users/PlasmaPower/followers","following_url":"https://api.github.com/users/PlasmaPower/following{/other_user}","gists_url":"https://api.github.com/users/PlasmaPower/gists{/gist_id}","starred_url":"https://api.github.com/users/PlasmaPower/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PlasmaPower/subscriptions","organizations_url":"https://api.github.com/users/PlasmaPower/orgs","repos_url":"https://api.github.com/users/PlasmaPower/repos","events_url":"https://api.github.com/users/PlasmaPower/events{/privacy}","received_events_url":"https://api.github.com/users/PlasmaPower/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PlasmaPower/cors","description":"Cross-Origin Resource Sharing(CORS) for koa","fork":true,"url":"https://api.github.com/repos/PlasmaPower/cors","forks_url":"https://api.github.com/repos/PlasmaPower/cors/forks","keys_url":"https://api.github.com/repos/PlasmaPower/cors/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PlasmaPower/cors/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PlasmaPower/cors/teams","hooks_url":"https://api.github.com/repos/PlasmaPower/cors/hooks","issue_events_url":"https://api.github.com/repos/PlasmaPower/cors/issues/events{/number}","events_url":"https://api.github.com/repos/PlasmaPower/cors/events","assignees_url":"https://api.github.com/repos/PlasmaPower/cors/assignees{/user}","branches_url":"https://api.github.com/repos/PlasmaPower/cors/branches{/branch}","tags_url":"https://api.github.com/repos/PlasmaPower/cors/tags","blobs_url":"https://api.github.com/repos/PlasmaPower/cors/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PlasmaPower/cors/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PlasmaPower/cors/git/refs{/sha}","trees_url":"https://api.github.com/repos/PlasmaPower/cors/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PlasmaPower/cors/statuses/{sha}","languages_url":"https://api.github.com/repos/PlasmaPower/cors/languages","stargazers_url":"https://api.github.com/repos/PlasmaPower/cors/stargazers","contributors_url":"https://api.github.com/repos/PlasmaPower/cors/contributors","subscribers_url":"https://api.github.com/repos/PlasmaPower/cors/subscribers","subscription_url":"https://api.github.com/repos/PlasmaPower/cors/subscription","commits_url":"https://api.github.com/repos/PlasmaPower/cors/commits{/sha}","git_commits_url":"https://api.github.com/repos/PlasmaPower/cors/git/commits{/sha}","comments_url":"https://api.github.com/repos/PlasmaPower/cors/comments{/number}","issue_comment_url":"https://api.github.com/repos/PlasmaPower/cors/issues/comments{/number}","contents_url":"https://api.github.com/repos/PlasmaPower/cors/contents/{+path}","compare_url":"https://api.github.com/repos/PlasmaPower/cors/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PlasmaPower/cors/merges","archive_url":"https://api.github.com/repos/PlasmaPower/cors/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PlasmaPower/cors/downloads","issues_url":"https://api.github.com/repos/PlasmaPower/cors/issues{/number}","pulls_url":"https://api.github.com/repos/PlasmaPower/cors/pulls{/number}","milestones_url":"https://api.github.com/repos/PlasmaPower/cors/milestones{/number}","notifications_url":"https://api.github.com/repos/PlasmaPower/cors/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PlasmaPower/cors/labels{/name}","releases_url":"https://api.github.com/repos/PlasmaPower/cors/releases{/id}","deployments_url":"https://api.github.com/repos/PlasmaPower/cors/deployments","created_at":"2016-03-15T21:30:40Z","updated_at":"2016-03-15T21:30:41Z","pushed_at":"2016-03-17T02:45:52Z","git_url":"git://github.com/PlasmaPower/cors.git","ssh_url":"git@github.com:PlasmaPower/cors.git","clone_url":"https://github.com/PlasmaPower/cors.git","svn_url":"https://github.com/PlasmaPower/cors","homepage":null,"size":18,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"koajs:master","ref":"master","sha":"c3a4281f7cc8a03e30a3052053da7f2b73caf1be","user":{"login":"koajs","id":5055057,"avatar_url":"https://avatars.githubusercontent.com/u/5055057?v=3","gravatar_id":"","url":"https://api.github.com/users/koajs","html_url":"https://github.com/koajs","followers_url":"https://api.github.com/users/koajs/followers","following_url":"https://api.github.com/users/koajs/following{/other_user}","gists_url":"https://api.github.com/users/koajs/gists{/gist_id}","starred_url":"https://api.github.com/users/koajs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koajs/subscriptions","organizations_url":"https://api.github.com/users/koajs/orgs","repos_url":"https://api.github.com/users/koajs/repos","events_url":"https://api.github.com/users/koajs/events{/privacy}","received_events_url":"https://api.github.com/users/koajs/received_events","type":"Organization","site_admin":false},"repo":{"id":30520411,"name":"cors","full_name":"koajs/cors","owner":{"login":"koajs","id":5055057,"avatar_url":"https://avatars.githubusercontent.com/u/5055057?v=3","gravatar_id":"","url":"https://api.github.com/users/koajs","html_url":"https://github.com/koajs","followers_url":"https://api.github.com/users/koajs/followers","following_url":"https://api.github.com/users/koajs/following{/other_user}","gists_url":"https://api.github.com/users/koajs/gists{/gist_id}","starred_url":"https://api.github.com/users/koajs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koajs/subscriptions","organizations_url":"https://api.github.com/users/koajs/orgs","repos_url":"https://api.github.com/users/koajs/repos","events_url":"https://api.github.com/users/koajs/events{/privacy}","received_events_url":"https://api.github.com/users/koajs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/koajs/cors","description":"Cross-Origin Resource Sharing(CORS) for koa","fork":false,"url":"https://api.github.com/repos/koajs/cors","forks_url":"https://api.github.com/repos/koajs/cors/forks","keys_url":"https://api.github.com/repos/koajs/cors/keys{/key_id}","collaborators_url":"https://api.github.com/repos/koajs/cors/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/koajs/cors/teams","hooks_url":"https://api.github.com/repos/koajs/cors/hooks","issue_events_url":"https://api.github.com/repos/koajs/cors/issues/events{/number}","events_url":"https://api.github.com/repos/koajs/cors/events","assignees_url":"https://api.github.com/repos/koajs/cors/assignees{/user}","branches_url":"https://api.github.com/repos/koajs/cors/branches{/branch}","tags_url":"https://api.github.com/repos/koajs/cors/tags","blobs_url":"https://api.github.com/repos/koajs/cors/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/koajs/cors/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/koajs/cors/git/refs{/sha}","trees_url":"https://api.github.com/repos/koajs/cors/git/trees{/sha}","statuses_url":"https://api.github.com/repos/koajs/cors/statuses/{sha}","languages_url":"https://api.github.com/repos/koajs/cors/languages","stargazers_url":"https://api.github.com/repos/koajs/cors/stargazers","contributors_url":"https://api.github.com/repos/koajs/cors/contributors","subscribers_url":"https://api.github.com/repos/koajs/cors/subscribers","subscription_url":"https://api.github.com/repos/koajs/cors/subscription","commits_url":"https://api.github.com/repos/koajs/cors/commits{/sha}","git_commits_url":"https://api.github.com/repos/koajs/cors/git/commits{/sha}","comments_url":"https://api.github.com/repos/koajs/cors/comments{/number}","issue_comment_url":"https://api.github.com/repos/koajs/cors/issues/comments{/number}","contents_url":"https://api.github.com/repos/koajs/cors/contents/{+path}","compare_url":"https://api.github.com/repos/koajs/cors/compare/{base}...{head}","merges_url":"https://api.github.com/repos/koajs/cors/merges","archive_url":"https://api.github.com/repos/koajs/cors/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/koajs/cors/downloads","issues_url":"https://api.github.com/repos/koajs/cors/issues{/number}","pulls_url":"https://api.github.com/repos/koajs/cors/pulls{/number}","milestones_url":"https://api.github.com/repos/koajs/cors/milestones{/number}","notifications_url":"https://api.github.com/repos/koajs/cors/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/koajs/cors/labels{/name}","releases_url":"https://api.github.com/repos/koajs/cors/releases{/id}","deployments_url":"https://api.github.com/repos/koajs/cors/deployments","created_at":"2015-02-09T05:34:31Z","updated_at":"2016-03-07T23:56:25Z","pushed_at":"2016-03-17T02:45:52Z","git_url":"git://github.com/koajs/cors.git","ssh_url":"git@github.com:koajs/cors.git","clone_url":"https://github.com/koajs/cors.git","svn_url":"https://github.com/koajs/cors","homepage":null,"size":25,"stargazers_count":20,"watchers_count":20,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":2,"forks":7,"open_issues":2,"watchers":20,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/koajs/cors/pulls/11"},"html":{"href":"https://github.com/koajs/cors/pull/11"},"issue":{"href":"https://api.github.com/repos/koajs/cors/issues/11"},"comments":{"href":"https://api.github.com/repos/koajs/cors/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/koajs/cors/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/koajs/cors/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/koajs/cors/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/koajs/cors/statuses/26afb4e5c74e270f9498b1c295e7e5705dc33f79"}}}}