GitHub PullRequestReviewCommentEvent at 2014-07-25 11:59:57
Repository: apiblueprintorg
Actor: kuba-kubula
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/apiaryio/apiblueprintorg/pulls/comments/15397454","id":15397454,"diff_hunk":"@@ -49,8 +48,27 @@ addCORS = (req, res, next) ->\n \n   next()\n \n+# In case clients use Accept-Charset and the request doesn't expect\n+# our response to be in utf-8, we strictly reject it with 406 Not Acceptable.\n+checkCharset = (req, res, next) ->\n+  if not req.acceptsCharset 'utf-8'\n+    res.set 'Content-Type', 'application/json'\n+    return res.send 406, if req.method is 'HEAD' then (new Buffer '') else\n+      message: 'The only supported encoding of response is utf-8.'\n+  next()\n \n-bodyParser = (req, res, next) ->\n+parseBody = (req, res, next) ->\n+  # Check Content-Type of the incoming data - in case it declares other\n+  # encoding than utf-8, we reject it with 415 Unsupported Media Type\n+  # (consulted the HTTP code with http://stackoverflow.com/a/11478530/325365).\n+  type = req.headers['content-type']","path":"app/controllers/api.coffee","position":39,"original_position":39,"commit_id":"8aa53f8b62db9a8f9de732d09908059b76b310e1","original_commit_id":"8aa53f8b62db9a8f9de732d09908059b76b310e1","user":{"login":"kuba-kubula","id":136198,"avatar_url":"https://avatars.githubusercontent.com/u/136198?","gravatar_id":"ba9e69315d0f4460caae5242bb93c745","url":"https://api.github.com/users/kuba-kubula","html_url":"https://github.com/kuba-kubula","followers_url":"https://api.github.com/users/kuba-kubula/followers","following_url":"https://api.github.com/users/kuba-kubula/following{/other_user}","gists_url":"https://api.github.com/users/kuba-kubula/gists{/gist_id}","starred_url":"https://api.github.com/users/kuba-kubula/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuba-kubula/subscriptions","organizations_url":"https://api.github.com/users/kuba-kubula/orgs","repos_url":"https://api.github.com/users/kuba-kubula/repos","events_url":"https://api.github.com/users/kuba-kubula/events{/privacy}","received_events_url":"https://api.github.com/users/kuba-kubula/received_events","type":"User","site_admin":false},"body":"please use `req.get 'content-type'` as it avoids lowerCase problems with header-keys.","created_at":"2014-07-25T11:59:57Z","updated_at":"2014-07-25T11:59:57Z","html_url":"https://github.com/apiaryio/apiblueprintorg/pull/13#discussion_r15397454","pull_request_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/apiaryio/apiblueprintorg/pulls/comments/15397454"},"html":{"href":"https://github.com/apiaryio/apiblueprintorg/pull/13#discussion_r15397454"},"pull_request":{"href":"https://api.github.com/repos/apiaryio/apiblueprintorg/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/apiaryio/apiblueprintorg/pulls/13","id":18486739,"html_url":"https://github.com/apiaryio/apiblueprintorg/pull/13","diff_url":"https://github.com/apiaryio/apiblueprintorg/pull/13.diff","patch_url":"https://github.com/apiaryio/apiblueprintorg/pull/13.patch","issue_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/issues/13","number":13,"state":"open","title":"Charset handling","user":{"login":"honzajavorek","id":283441,"avatar_url":"https://avatars.githubusercontent.com/u/283441?","gravatar_id":"7b2e4bf7ecca28e530e1c421f0676c0b","url":"https://api.github.com/users/honzajavorek","html_url":"https://github.com/honzajavorek","followers_url":"https://api.github.com/users/honzajavorek/followers","following_url":"https://api.github.com/users/honzajavorek/following{/other_user}","gists_url":"https://api.github.com/users/honzajavorek/gists{/gist_id}","starred_url":"https://api.github.com/users/honzajavorek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/honzajavorek/subscriptions","organizations_url":"https://api.github.com/users/honzajavorek/orgs","repos_url":"https://api.github.com/users/honzajavorek/repos","events_url":"https://api.github.com/users/honzajavorek/events{/privacy}","received_events_url":"https://api.github.com/users/honzajavorek/received_events","type":"User","site_admin":false},"body":"https://trello.com/c/NTKofski/1744-api-blueprint-api-charset-behavior\r\n\r\nImplements charset handling discussed here: https://github.com/apiaryio/apiblueprintorg/pull/7#issuecomment-49074506\r\n\r\nBEWARE: This branch is builds upon code in https://github.com/apiaryio/apiblueprintorg/pull/12, so until that one is merged, this shouldn't be considered for review or merge.\r\n\r\nImplementation:\r\n\r\n- all responses are in utf-8\r\n- `/composer` responds with `text/vnd.apiblueprint+markdown; charset=utf-8` - includes charset, because it's `text/...`\r\n- other stuff is served without charset in `Content-Type`, because it's redundant and it could confuse people or encourage them to try different charsets\r\n- payload is accepted only as utf-8 - if any mention about charset is missing, utf-8 is assumed; if content type of incoming data has charset parameter, it has to be utf-8, otherwise the request is rejected\r\n- if client sends `Accept-Encoding` and its content doesn't expect the response to be in utf-8, request is also rejected","created_at":"2014-07-16T18:43:09Z","updated_at":"2014-07-25T11:59:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f49407c367035e5b1f2846f117744566a7d9a62d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/pulls/13/commits","review_comments_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/pulls/13/comments","review_comment_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/pulls/comments/{number}","comments_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/issues/13/comments","statuses_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/statuses/8aa53f8b62db9a8f9de732d09908059b76b310e1","head":{"label":"apiaryio:hj/charset","ref":"hj/charset","sha":"8aa53f8b62db9a8f9de732d09908059b76b310e1","user":{"login":"apiaryio","id":765943,"avatar_url":"https://avatars.githubusercontent.com/u/765943?","gravatar_id":"c64b5c51ede2fbd878595bf27bc4d630","url":"https://api.github.com/users/apiaryio","html_url":"https://github.com/apiaryio","followers_url":"https://api.github.com/users/apiaryio/followers","following_url":"https://api.github.com/users/apiaryio/following{/other_user}","gists_url":"https://api.github.com/users/apiaryio/gists{/gist_id}","starred_url":"https://api.github.com/users/apiaryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apiaryio/subscriptions","organizations_url":"https://api.github.com/users/apiaryio/orgs","repos_url":"https://api.github.com/users/apiaryio/repos","events_url":"https://api.github.com/users/apiaryio/events{/privacy}","received_events_url":"https://api.github.com/users/apiaryio/received_events","type":"Organization","site_admin":false},"repo":{"id":21393045,"name":"apiblueprintorg","full_name":"apiaryio/apiblueprintorg","owner":{"login":"apiaryio","id":765943,"avatar_url":"https://avatars.githubusercontent.com/u/765943?","gravatar_id":"c64b5c51ede2fbd878595bf27bc4d630","url":"https://api.github.com/users/apiaryio","html_url":"https://github.com/apiaryio","followers_url":"https://api.github.com/users/apiaryio/followers","following_url":"https://api.github.com/users/apiaryio/following{/other_user}","gists_url":"https://api.github.com/users/apiaryio/gists{/gist_id}","starred_url":"https://api.github.com/users/apiaryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apiaryio/subscriptions","organizations_url":"https://api.github.com/users/apiaryio/orgs","repos_url":"https://api.github.com/users/apiaryio/repos","events_url":"https://api.github.com/users/apiaryio/events{/privacy}","received_events_url":"https://api.github.com/users/apiaryio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apiaryio/apiblueprintorg","description":"apiblueprint.org site","fork":false,"url":"https://api.github.com/repos/apiaryio/apiblueprintorg","forks_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/forks","keys_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/teams","hooks_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/hooks","issue_events_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/issues/events{/number}","events_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/events","assignees_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/assignees{/user}","branches_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/branches{/branch}","tags_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/tags","blobs_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/git/refs{/sha}","trees_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/statuses/{sha}","languages_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/languages","stargazers_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/stargazers","contributors_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/contributors","subscribers_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/subscribers","subscription_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/subscription","commits_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/commits{/sha}","git_commits_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/git/commits{/sha}","comments_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/comments{/number}","issue_comment_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/issues/comments/{number}","contents_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/contents/{+path}","compare_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/merges","archive_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/downloads","issues_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/issues{/number}","pulls_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/pulls{/number}","milestones_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/milestones{/number}","notifications_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/labels{/name}","releases_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/releases{/id}","created_at":"2014-07-01T15:32:56Z","updated_at":"2014-07-02T09:00:15Z","pushed_at":"2014-07-25T11:55:06Z","git_url":"git://github.com/apiaryio/apiblueprintorg.git","ssh_url":"git@github.com:apiaryio/apiblueprintorg.git","clone_url":"https://github.com/apiaryio/apiblueprintorg.git","svn_url":"https://github.com/apiaryio/apiblueprintorg","homepage":"http://apiblueprint.org","size":2811,"stargazers_count":1,"watchers_count":1,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"apiaryio:master","ref":"master","sha":"2bb6b6de1af1e543430908f7db11cb6c5054027e","user":{"login":"apiaryio","id":765943,"avatar_url":"https://avatars.githubusercontent.com/u/765943?","gravatar_id":"c64b5c51ede2fbd878595bf27bc4d630","url":"https://api.github.com/users/apiaryio","html_url":"https://github.com/apiaryio","followers_url":"https://api.github.com/users/apiaryio/followers","following_url":"https://api.github.com/users/apiaryio/following{/other_user}","gists_url":"https://api.github.com/users/apiaryio/gists{/gist_id}","starred_url":"https://api.github.com/users/apiaryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apiaryio/subscriptions","organizations_url":"https://api.github.com/users/apiaryio/orgs","repos_url":"https://api.github.com/users/apiaryio/repos","events_url":"https://api.github.com/users/apiaryio/events{/privacy}","received_events_url":"https://api.github.com/users/apiaryio/received_events","type":"Organization","site_admin":false},"repo":{"id":21393045,"name":"apiblueprintorg","full_name":"apiaryio/apiblueprintorg","owner":{"login":"apiaryio","id":765943,"avatar_url":"https://avatars.githubusercontent.com/u/765943?","gravatar_id":"c64b5c51ede2fbd878595bf27bc4d630","url":"https://api.github.com/users/apiaryio","html_url":"https://github.com/apiaryio","followers_url":"https://api.github.com/users/apiaryio/followers","following_url":"https://api.github.com/users/apiaryio/following{/other_user}","gists_url":"https://api.github.com/users/apiaryio/gists{/gist_id}","starred_url":"https://api.github.com/users/apiaryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apiaryio/subscriptions","organizations_url":"https://api.github.com/users/apiaryio/orgs","repos_url":"https://api.github.com/users/apiaryio/repos","events_url":"https://api.github.com/users/apiaryio/events{/privacy}","received_events_url":"https://api.github.com/users/apiaryio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apiaryio/apiblueprintorg","description":"apiblueprint.org site","fork":false,"url":"https://api.github.com/repos/apiaryio/apiblueprintorg","forks_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/forks","keys_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/teams","hooks_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/hooks","issue_events_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/issues/events{/number}","events_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/events","assignees_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/assignees{/user}","branches_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/branches{/branch}","tags_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/tags","blobs_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/git/refs{/sha}","trees_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/statuses/{sha}","languages_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/languages","stargazers_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/stargazers","contributors_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/contributors","subscribers_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/subscribers","subscription_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/subscription","commits_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/commits{/sha}","git_commits_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/git/commits{/sha}","comments_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/comments{/number}","issue_comment_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/issues/comments/{number}","contents_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/contents/{+path}","compare_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/merges","archive_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/downloads","issues_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/issues{/number}","pulls_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/pulls{/number}","milestones_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/milestones{/number}","notifications_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/labels{/name}","releases_url":"https://api.github.com/repos/apiaryio/apiblueprintorg/releases{/id}","created_at":"2014-07-01T15:32:56Z","updated_at":"2014-07-02T09:00:15Z","pushed_at":"2014-07-25T11:55:06Z","git_url":"git://github.com/apiaryio/apiblueprintorg.git","ssh_url":"git@github.com:apiaryio/apiblueprintorg.git","clone_url":"https://github.com/apiaryio/apiblueprintorg.git","svn_url":"https://github.com/apiaryio/apiblueprintorg","homepage":"http://apiblueprint.org","size":2811,"stargazers_count":1,"watchers_count":1,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apiaryio/apiblueprintorg/pulls/13"},"html":{"href":"https://github.com/apiaryio/apiblueprintorg/pull/13"},"issue":{"href":"https://api.github.com/repos/apiaryio/apiblueprintorg/issues/13"},"comments":{"href":"https://api.github.com/repos/apiaryio/apiblueprintorg/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/apiaryio/apiblueprintorg/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/apiaryio/apiblueprintorg/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/apiaryio/apiblueprintorg/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/apiaryio/apiblueprintorg/statuses/8aa53f8b62db9a8f9de732d09908059b76b310e1"}}}}