{"action":"created","comment":{"url":"https://api.github.com/repos/nodejs/docs/pulls/comments/36593366","id":36593366,"diff_hunk":"@@ -0,0 +1,429 @@\n+# Anatomy of an HTTP Request\n+\n+The purpose of this guide is to impart a solid understanding of the process of\n+Node.js HTTP handling. We'll assume that you know, in a general sense, how HTTP\n+requests work, regardless of language or programming environment. We'll also\n+assume a bit of familiarity with Node.js [`EventEmitters`][] and [`Streams`][].\n+If you're not quite familiar with them, it's worth taking a quick read through\n+the API docs for each of those.\n+\n+## Create the Server\n+\n+Any node web server application will at some point have to create a web server\n+object. This is done by using [`createServer`][].\n+\n+```javascript\n+var http = require('http');\n+\n+var server = http.createServer(function(request, response) {\n+  // magic happens here!\n+});\n+```\n+\n+The function that's passed in to [`createServer`][] is called once for every\n+HTTP request that's made against that server, so it's called the request\n+handler. In fact, the [`Server`][] object returned by [`createServer`][] is an\n+[`EventEmitter`][], and what we have here is just shorthand for creating a\n+`server` object and then adding the listener later.\n+\n+```javascript\n+var server = http.createServer();\n+server.on('request', function(request, response) {\n+  // the same kind of magic happens here!\n+});\n+```\n+\n+When an HTTP request hits the server, node calls the request handler function\n+with a few handy object for dealing with the transaction, `request` and","path":"src/guides/anatomy-of-an-http-transaction.md","position":37,"original_position":37,"commit_id":"bc1aff739fc4807da909219c54f31ec832d9df73","original_commit_id":"bc1aff739fc4807da909219c54f31ec832d9df73","user":{"login":"chrisdickinson","id":37303,"avatar_url":"https://avatars.githubusercontent.com/u/37303?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisdickinson","html_url":"https://github.com/chrisdickinson","followers_url":"https://api.github.com/users/chrisdickinson/followers","following_url":"https://api.github.com/users/chrisdickinson/following{/other_user}","gists_url":"https://api.github.com/users/chrisdickinson/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisdickinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisdickinson/subscriptions","organizations_url":"https://api.github.com/users/chrisdickinson/orgs","repos_url":"https://api.github.com/users/chrisdickinson/repos","events_url":"https://api.github.com/users/chrisdickinson/events{/privacy}","received_events_url":"https://api.github.com/users/chrisdickinson/received_events","type":"User","site_admin":false},"body":"\"object\" should be pluralized.","created_at":"2015-08-09T20:40:12Z","updated_at":"2015-08-09T20:40:12Z","html_url":"https://github.com/nodejs/docs/pull/27#discussion_r36593366","pull_request_url":"https://api.github.com/repos/nodejs/docs/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/nodejs/docs/pulls/comments/36593366"},"html":{"href":"https://github.com/nodejs/docs/pull/27#discussion_r36593366"},"pull_request":{"href":"https://api.github.com/repos/nodejs/docs/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/nodejs/docs/pulls/27","id":41526190,"html_url":"https://github.com/nodejs/docs/pull/27","diff_url":"https://github.com/nodejs/docs/pull/27.diff","patch_url":"https://github.com/nodejs/docs/pull/27.patch","issue_url":"https://api.github.com/repos/nodejs/docs/issues/27","number":27,"state":"open","locked":false,"title":"First draft of \"Anatomy of an HTTP Request\"","user":{"login":"bengl","id":110455,"avatar_url":"https://avatars.githubusercontent.com/u/110455?v=3","gravatar_id":"","url":"https://api.github.com/users/bengl","html_url":"https://github.com/bengl","followers_url":"https://api.github.com/users/bengl/followers","following_url":"https://api.github.com/users/bengl/following{/other_user}","gists_url":"https://api.github.com/users/bengl/gists{/gist_id}","starred_url":"https://api.github.com/users/bengl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bengl/subscriptions","organizations_url":"https://api.github.com/users/bengl/orgs","repos_url":"https://api.github.com/users/bengl/repos","events_url":"https://api.github.com/users/bengl/events{/privacy}","received_events_url":"https://api.github.com/users/bengl/received_events","type":"User","site_admin":false},"body":"This is #21 realized.\r\n\r\nI wasn't sure if this would be better as a guide or a topic, but left it in guides for now.\r\n\r\nI linked to the io.js API docs instead of node.js API docs, since I wanted to link to the [new Errors doc](https://iojs.org/api/errors.html).","created_at":"2015-08-04T01:17:12Z","updated_at":"2015-08-09T20:40:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c60efc0b348569af594bf1ebcbc740db975daf22","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nodejs/docs/pulls/27/commits","review_comments_url":"https://api.github.com/repos/nodejs/docs/pulls/27/comments","review_comment_url":"https://api.github.com/repos/nodejs/docs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodejs/docs/issues/27/comments","statuses_url":"https://api.github.com/repos/nodejs/docs/statuses/bc1aff739fc4807da909219c54f31ec832d9df73","head":{"label":"bengl:httpreq_guide","ref":"httpreq_guide","sha":"bc1aff739fc4807da909219c54f31ec832d9df73","user":{"login":"bengl","id":110455,"avatar_url":"https://avatars.githubusercontent.com/u/110455?v=3","gravatar_id":"","url":"https://api.github.com/users/bengl","html_url":"https://github.com/bengl","followers_url":"https://api.github.com/users/bengl/followers","following_url":"https://api.github.com/users/bengl/following{/other_user}","gists_url":"https://api.github.com/users/bengl/gists{/gist_id}","starred_url":"https://api.github.com/users/bengl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bengl/subscriptions","organizations_url":"https://api.github.com/users/bengl/orgs","repos_url":"https://api.github.com/users/bengl/repos","events_url":"https://api.github.com/users/bengl/events{/privacy}","received_events_url":"https://api.github.com/users/bengl/received_events","type":"User","site_admin":false},"repo":{"id":40155880,"name":"docs","full_name":"bengl/docs","owner":{"login":"bengl","id":110455,"avatar_url":"https://avatars.githubusercontent.com/u/110455?v=3","gravatar_id":"","url":"https://api.github.com/users/bengl","html_url":"https://github.com/bengl","followers_url":"https://api.github.com/users/bengl/followers","following_url":"https://api.github.com/users/bengl/following{/other_user}","gists_url":"https://api.github.com/users/bengl/gists{/gist_id}","starred_url":"https://api.github.com/users/bengl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bengl/subscriptions","organizations_url":"https://api.github.com/users/bengl/orgs","repos_url":"https://api.github.com/users/bengl/repos","events_url":"https://api.github.com/users/bengl/events{/privacy}","received_events_url":"https://api.github.com/users/bengl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bengl/docs","description":"A place for documentation.","fork":true,"url":"https://api.github.com/repos/bengl/docs","forks_url":"https://api.github.com/repos/bengl/docs/forks","keys_url":"https://api.github.com/repos/bengl/docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bengl/docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bengl/docs/teams","hooks_url":"https://api.github.com/repos/bengl/docs/hooks","issue_events_url":"https://api.github.com/repos/bengl/docs/issues/events{/number}","events_url":"https://api.github.com/repos/bengl/docs/events","assignees_url":"https://api.github.com/repos/bengl/docs/assignees{/user}","branches_url":"https://api.github.com/repos/bengl/docs/branches{/branch}","tags_url":"https://api.github.com/repos/bengl/docs/tags","blobs_url":"https://api.github.com/repos/bengl/docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bengl/docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bengl/docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/bengl/docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bengl/docs/statuses/{sha}","languages_url":"https://api.github.com/repos/bengl/docs/languages","stargazers_url":"https://api.github.com/repos/bengl/docs/stargazers","contributors_url":"https://api.github.com/repos/bengl/docs/contributors","subscribers_url":"https://api.github.com/repos/bengl/docs/subscribers","subscription_url":"https://api.github.com/repos/bengl/docs/subscription","commits_url":"https://api.github.com/repos/bengl/docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/bengl/docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/bengl/docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/bengl/docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/bengl/docs/contents/{+path}","compare_url":"https://api.github.com/repos/bengl/docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bengl/docs/merges","archive_url":"https://api.github.com/repos/bengl/docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bengl/docs/downloads","issues_url":"https://api.github.com/repos/bengl/docs/issues{/number}","pulls_url":"https://api.github.com/repos/bengl/docs/pulls{/number}","milestones_url":"https://api.github.com/repos/bengl/docs/milestones{/number}","notifications_url":"https://api.github.com/repos/bengl/docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bengl/docs/labels{/name}","releases_url":"https://api.github.com/repos/bengl/docs/releases{/id}","created_at":"2015-08-04T01:10:42Z","updated_at":"2015-07-08T03:13:40Z","pushed_at":"2015-08-09T18:22:15Z","git_url":"git://github.com/bengl/docs.git","ssh_url":"git@github.com:bengl/docs.git","clone_url":"https://github.com/bengl/docs.git","svn_url":"https://github.com/bengl/docs","homepage":null,"size":105,"stargazers_count":0,"watchers_count":0,"language":null,"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":"nodejs:master","ref":"master","sha":"cef3dca3d9752f90f1e9853d3d01f8e9aa33c74e","user":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"repo":{"id":37390671,"name":"docs","full_name":"nodejs/docs","owner":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nodejs/docs","description":"A place for documentation.","fork":false,"url":"https://api.github.com/repos/nodejs/docs","forks_url":"https://api.github.com/repos/nodejs/docs/forks","keys_url":"https://api.github.com/repos/nodejs/docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodejs/docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodejs/docs/teams","hooks_url":"https://api.github.com/repos/nodejs/docs/hooks","issue_events_url":"https://api.github.com/repos/nodejs/docs/issues/events{/number}","events_url":"https://api.github.com/repos/nodejs/docs/events","assignees_url":"https://api.github.com/repos/nodejs/docs/assignees{/user}","branches_url":"https://api.github.com/repos/nodejs/docs/branches{/branch}","tags_url":"https://api.github.com/repos/nodejs/docs/tags","blobs_url":"https://api.github.com/repos/nodejs/docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodejs/docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodejs/docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodejs/docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodejs/docs/statuses/{sha}","languages_url":"https://api.github.com/repos/nodejs/docs/languages","stargazers_url":"https://api.github.com/repos/nodejs/docs/stargazers","contributors_url":"https://api.github.com/repos/nodejs/docs/contributors","subscribers_url":"https://api.github.com/repos/nodejs/docs/subscribers","subscription_url":"https://api.github.com/repos/nodejs/docs/subscription","commits_url":"https://api.github.com/repos/nodejs/docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodejs/docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodejs/docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodejs/docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodejs/docs/contents/{+path}","compare_url":"https://api.github.com/repos/nodejs/docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodejs/docs/merges","archive_url":"https://api.github.com/repos/nodejs/docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodejs/docs/downloads","issues_url":"https://api.github.com/repos/nodejs/docs/issues{/number}","pulls_url":"https://api.github.com/repos/nodejs/docs/pulls{/number}","milestones_url":"https://api.github.com/repos/nodejs/docs/milestones{/number}","notifications_url":"https://api.github.com/repos/nodejs/docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodejs/docs/labels{/name}","releases_url":"https://api.github.com/repos/nodejs/docs/releases{/id}","created_at":"2015-06-13T22:48:59Z","updated_at":"2015-07-08T03:13:40Z","pushed_at":"2015-08-09T18:22:16Z","git_url":"git://github.com/nodejs/docs.git","ssh_url":"git@github.com:nodejs/docs.git","clone_url":"https://github.com/nodejs/docs.git","svn_url":"https://github.com/nodejs/docs","homepage":null,"size":279,"stargazers_count":16,"watchers_count":16,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":21,"forks":7,"open_issues":21,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodejs/docs/pulls/27"},"html":{"href":"https://github.com/nodejs/docs/pull/27"},"issue":{"href":"https://api.github.com/repos/nodejs/docs/issues/27"},"comments":{"href":"https://api.github.com/repos/nodejs/docs/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/nodejs/docs/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/nodejs/docs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodejs/docs/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/nodejs/docs/statuses/bc1aff739fc4807da909219c54f31ec832d9df73"}}}}