{"action":"created","comment":{"url":"https://api.github.com/repos/servo/servo/pulls/comments/79839478","id":79839478,"diff_hunk":"@@ -178,6 +178,65 @@ impl Response {\n         // Step 7\n         Ok(r)\n     }\n+\n+    // https://fetch.spec.whatwg.org/#concept-body-consume-body\n+    #[allow(unrooted_must_root)]\n+    fn consume_body(&self, body_type: BodyType) -> Fallible<Rc<Promise>> {\n+        let promise = Promise::new(self.global().r());\n+\n+        // Step 1\n+        if self.BodyUsed() || self.locked() {\n+            promise.maybe_reject_error(promise.global().r().get_cx(), Error::Type(\n+                \"The response's stream is disturbed or locked\".to_string()));\n+            return Ok(promise);\n+        }\n+\n+        // Steps 2-4\n+        // TODO: Body does not yet have a stream.\n+\n+        // Step 5\n+        let pkg_data_results: String = try!(self.run_package_data_algorithm(body_type));\n+        let pkg_data_results: USVString = USVString(pkg_data_results);\n+        promise.maybe_resolve_native(promise.global().r().get_cx(), &pkg_data_results);\n+        Ok(promise)\n+    }\n+\n+    // https://fetch.spec.whatwg.org/#concept-body-locked\n+    fn locked(&self) -> bool {\n+        // TODO: ReadableStream is unimplemented. Just return false\n+        // for now.\n+        false\n+    }\n+\n+    // https://fetch.spec.whatwg.org/#concept-body-package-data\n+    fn run_package_data_algorithm(&self, body_type: BodyType) -> Fallible<String> {\n+        match body_type {\n+            BodyType::Text => {\n+                // return result of running utf-8 decode here\n+                // using encoding crate on all bytes instead of\n+                // individually processing each token\n+                // TODO: also check NetTraitsResponseBody::Receiving(bytes) = *self.body.borrow()\n+                if let NetTraitsResponseBody::Done(ref bytes) = *self.body.borrow() {\n+                    self.body_used.set(true);\n+                    let result: Result<String, Error> =\n+                        UTF_8.decode(bytes, DecoderTrap::Replace).map_err(|e| Error::Type((&*e).to_owned()));","path":"components/script/dom/response.rs","position":128,"original_position":128,"commit_id":"5087c77eea51019a8471589c957b5bb11f66b5a1","original_commit_id":"5087c77eea51019a8471589c957b5bb11f66b5a1","user":{"login":"jdm","id":27658,"avatar_url":"https://avatars.githubusercontent.com/u/27658?v=3","gravatar_id":"","url":"https://api.github.com/users/jdm","html_url":"https://github.com/jdm","followers_url":"https://api.github.com/users/jdm/followers","following_url":"https://api.github.com/users/jdm/following{/other_user}","gists_url":"https://api.github.com/users/jdm/gists{/gist_id}","starred_url":"https://api.github.com/users/jdm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdm/subscriptions","organizations_url":"https://api.github.com/users/jdm/orgs","repos_url":"https://api.github.com/users/jdm/repos","events_url":"https://api.github.com/users/jdm/events{/privacy}","received_events_url":"https://api.github.com/users/jdm/received_events","type":"User","site_admin":false},"body":"We can use `unwrap` instead of returning an error here; the UTF-8 decoder with the Replace argument is infallible (since any decoding errors get replaced with valid characters).","created_at":"2016-09-21T14:00:35Z","updated_at":"2016-09-21T14:10:16Z","html_url":"https://github.com/servo/servo/pull/13345#discussion_r79839478","pull_request_url":"https://api.github.com/repos/servo/servo/pulls/13345","_links":{"self":{"href":"https://api.github.com/repos/servo/servo/pulls/comments/79839478"},"html":{"href":"https://github.com/servo/servo/pull/13345#discussion_r79839478"},"pull_request":{"href":"https://api.github.com/repos/servo/servo/pulls/13345"}}},"pull_request":{"url":"https://api.github.com/repos/servo/servo/pulls/13345","id":86093694,"html_url":"https://github.com/servo/servo/pull/13345","diff_url":"https://github.com/servo/servo/pull/13345.diff","patch_url":"https://github.com/servo/servo/pull/13345.patch","issue_url":"https://api.github.com/repos/servo/servo/issues/13345","number":13345,"state":"open","locked":false,"title":"implement Body::text for dom::Response","user":{"login":"malisas","id":16787492,"avatar_url":"https://avatars.githubusercontent.com/u/16787492?v=3","gravatar_id":"","url":"https://api.github.com/users/malisas","html_url":"https://github.com/malisas","followers_url":"https://api.github.com/users/malisas/followers","following_url":"https://api.github.com/users/malisas/following{/other_user}","gists_url":"https://api.github.com/users/malisas/gists{/gist_id}","starred_url":"https://api.github.com/users/malisas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malisas/subscriptions","organizations_url":"https://api.github.com/users/malisas/orgs","repos_url":"https://api.github.com/users/malisas/repos","events_url":"https://api.github.com/users/malisas/events{/privacy}","received_events_url":"https://api.github.com/users/malisas/received_events","type":"User","site_admin":false},"body":"<!-- Please describe your changes on the following line: -->\r\n\r\nThis PR adds dom::Response's `Text()` function, part of the [Body mixin](https://fetch.spec.whatwg.org/#body).\r\n\r\nAlthough Body is still incomplete, my understanding is that a partial implementation will be enough to help move the Fetch implementation forward.\r\n\r\n---\r\n<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->\r\n- [X] `./mach build -d` does not report any errors\r\n- [X] `./mach test-tidy` does not report any errors\r\n- [ ] These changes fix #__ (github issue number if applicable).\r\n\r\n<!-- Either: -->\r\n- [X] There are tests for these changes OR\r\n- [ ] These changes do not require tests because _____\r\n\r\n<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/servo/servo/13345)\n<!-- Reviewable:end -->\n","created_at":"2016-09-21T03:48:23Z","updated_at":"2016-09-21T14:10:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cc627cefc854ba1be0b8ef909a68911492f814e7","assignee":{"login":"jdm","id":27658,"avatar_url":"https://avatars.githubusercontent.com/u/27658?v=3","gravatar_id":"","url":"https://api.github.com/users/jdm","html_url":"https://github.com/jdm","followers_url":"https://api.github.com/users/jdm/followers","following_url":"https://api.github.com/users/jdm/following{/other_user}","gists_url":"https://api.github.com/users/jdm/gists{/gist_id}","starred_url":"https://api.github.com/users/jdm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdm/subscriptions","organizations_url":"https://api.github.com/users/jdm/orgs","repos_url":"https://api.github.com/users/jdm/repos","events_url":"https://api.github.com/users/jdm/events{/privacy}","received_events_url":"https://api.github.com/users/jdm/received_events","type":"User","site_admin":false},"assignees":[{"login":"jdm","id":27658,"avatar_url":"https://avatars.githubusercontent.com/u/27658?v=3","gravatar_id":"","url":"https://api.github.com/users/jdm","html_url":"https://github.com/jdm","followers_url":"https://api.github.com/users/jdm/followers","following_url":"https://api.github.com/users/jdm/following{/other_user}","gists_url":"https://api.github.com/users/jdm/gists{/gist_id}","starred_url":"https://api.github.com/users/jdm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdm/subscriptions","organizations_url":"https://api.github.com/users/jdm/orgs","repos_url":"https://api.github.com/users/jdm/repos","events_url":"https://api.github.com/users/jdm/events{/privacy}","received_events_url":"https://api.github.com/users/jdm/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/servo/servo/pulls/13345/commits","review_comments_url":"https://api.github.com/repos/servo/servo/pulls/13345/comments","review_comment_url":"https://api.github.com/repos/servo/servo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/servo/servo/issues/13345/comments","statuses_url":"https://api.github.com/repos/servo/servo/statuses/5087c77eea51019a8471589c957b5bb11f66b5a1","head":{"label":"malisas:malisa-bodyAPI","ref":"malisa-bodyAPI","sha":"5087c77eea51019a8471589c957b5bb11f66b5a1","user":{"login":"malisas","id":16787492,"avatar_url":"https://avatars.githubusercontent.com/u/16787492?v=3","gravatar_id":"","url":"https://api.github.com/users/malisas","html_url":"https://github.com/malisas","followers_url":"https://api.github.com/users/malisas/followers","following_url":"https://api.github.com/users/malisas/following{/other_user}","gists_url":"https://api.github.com/users/malisas/gists{/gist_id}","starred_url":"https://api.github.com/users/malisas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malisas/subscriptions","organizations_url":"https://api.github.com/users/malisas/orgs","repos_url":"https://api.github.com/users/malisas/repos","events_url":"https://api.github.com/users/malisas/events{/privacy}","received_events_url":"https://api.github.com/users/malisas/received_events","type":"User","site_admin":false},"repo":{"id":62736214,"name":"servo","full_name":"malisas/servo","owner":{"login":"malisas","id":16787492,"avatar_url":"https://avatars.githubusercontent.com/u/16787492?v=3","gravatar_id":"","url":"https://api.github.com/users/malisas","html_url":"https://github.com/malisas","followers_url":"https://api.github.com/users/malisas/followers","following_url":"https://api.github.com/users/malisas/following{/other_user}","gists_url":"https://api.github.com/users/malisas/gists{/gist_id}","starred_url":"https://api.github.com/users/malisas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malisas/subscriptions","organizations_url":"https://api.github.com/users/malisas/orgs","repos_url":"https://api.github.com/users/malisas/repos","events_url":"https://api.github.com/users/malisas/events{/privacy}","received_events_url":"https://api.github.com/users/malisas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/malisas/servo","description":"The Servo Browser Engine","fork":true,"url":"https://api.github.com/repos/malisas/servo","forks_url":"https://api.github.com/repos/malisas/servo/forks","keys_url":"https://api.github.com/repos/malisas/servo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/malisas/servo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/malisas/servo/teams","hooks_url":"https://api.github.com/repos/malisas/servo/hooks","issue_events_url":"https://api.github.com/repos/malisas/servo/issues/events{/number}","events_url":"https://api.github.com/repos/malisas/servo/events","assignees_url":"https://api.github.com/repos/malisas/servo/assignees{/user}","branches_url":"https://api.github.com/repos/malisas/servo/branches{/branch}","tags_url":"https://api.github.com/repos/malisas/servo/tags","blobs_url":"https://api.github.com/repos/malisas/servo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/malisas/servo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/malisas/servo/git/refs{/sha}","trees_url":"https://api.github.com/repos/malisas/servo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/malisas/servo/statuses/{sha}","languages_url":"https://api.github.com/repos/malisas/servo/languages","stargazers_url":"https://api.github.com/repos/malisas/servo/stargazers","contributors_url":"https://api.github.com/repos/malisas/servo/contributors","subscribers_url":"https://api.github.com/repos/malisas/servo/subscribers","subscription_url":"https://api.github.com/repos/malisas/servo/subscription","commits_url":"https://api.github.com/repos/malisas/servo/commits{/sha}","git_commits_url":"https://api.github.com/repos/malisas/servo/git/commits{/sha}","comments_url":"https://api.github.com/repos/malisas/servo/comments{/number}","issue_comment_url":"https://api.github.com/repos/malisas/servo/issues/comments{/number}","contents_url":"https://api.github.com/repos/malisas/servo/contents/{+path}","compare_url":"https://api.github.com/repos/malisas/servo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/malisas/servo/merges","archive_url":"https://api.github.com/repos/malisas/servo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/malisas/servo/downloads","issues_url":"https://api.github.com/repos/malisas/servo/issues{/number}","pulls_url":"https://api.github.com/repos/malisas/servo/pulls{/number}","milestones_url":"https://api.github.com/repos/malisas/servo/milestones{/number}","notifications_url":"https://api.github.com/repos/malisas/servo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/malisas/servo/labels{/name}","releases_url":"https://api.github.com/repos/malisas/servo/releases{/id}","deployments_url":"https://api.github.com/repos/malisas/servo/deployments","created_at":"2016-07-06T16:24:00Z","updated_at":"2016-07-06T15:38:52Z","pushed_at":"2016-09-21T03:34:06Z","git_url":"git://github.com/malisas/servo.git","ssh_url":"git@github.com:malisas/servo.git","clone_url":"https://github.com/malisas/servo.git","svn_url":"https://github.com/malisas/servo","homepage":"https://servo.org/","size":208632,"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":"servo:master","ref":"master","sha":"7c0dfd07ad5149406b389ca893d51f6fa442e98e","user":{"login":"servo","id":2566135,"avatar_url":"https://avatars.githubusercontent.com/u/2566135?v=3","gravatar_id":"","url":"https://api.github.com/users/servo","html_url":"https://github.com/servo","followers_url":"https://api.github.com/users/servo/followers","following_url":"https://api.github.com/users/servo/following{/other_user}","gists_url":"https://api.github.com/users/servo/gists{/gist_id}","starred_url":"https://api.github.com/users/servo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/servo/subscriptions","organizations_url":"https://api.github.com/users/servo/orgs","repos_url":"https://api.github.com/users/servo/repos","events_url":"https://api.github.com/users/servo/events{/privacy}","received_events_url":"https://api.github.com/users/servo/received_events","type":"Organization","site_admin":false},"repo":{"id":3390243,"name":"servo","full_name":"servo/servo","owner":{"login":"servo","id":2566135,"avatar_url":"https://avatars.githubusercontent.com/u/2566135?v=3","gravatar_id":"","url":"https://api.github.com/users/servo","html_url":"https://github.com/servo","followers_url":"https://api.github.com/users/servo/followers","following_url":"https://api.github.com/users/servo/following{/other_user}","gists_url":"https://api.github.com/users/servo/gists{/gist_id}","starred_url":"https://api.github.com/users/servo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/servo/subscriptions","organizations_url":"https://api.github.com/users/servo/orgs","repos_url":"https://api.github.com/users/servo/repos","events_url":"https://api.github.com/users/servo/events{/privacy}","received_events_url":"https://api.github.com/users/servo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/servo/servo","description":"The Servo Browser Engine","fork":false,"url":"https://api.github.com/repos/servo/servo","forks_url":"https://api.github.com/repos/servo/servo/forks","keys_url":"https://api.github.com/repos/servo/servo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/servo/servo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/servo/servo/teams","hooks_url":"https://api.github.com/repos/servo/servo/hooks","issue_events_url":"https://api.github.com/repos/servo/servo/issues/events{/number}","events_url":"https://api.github.com/repos/servo/servo/events","assignees_url":"https://api.github.com/repos/servo/servo/assignees{/user}","branches_url":"https://api.github.com/repos/servo/servo/branches{/branch}","tags_url":"https://api.github.com/repos/servo/servo/tags","blobs_url":"https://api.github.com/repos/servo/servo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/servo/servo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/servo/servo/git/refs{/sha}","trees_url":"https://api.github.com/repos/servo/servo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/servo/servo/statuses/{sha}","languages_url":"https://api.github.com/repos/servo/servo/languages","stargazers_url":"https://api.github.com/repos/servo/servo/stargazers","contributors_url":"https://api.github.com/repos/servo/servo/contributors","subscribers_url":"https://api.github.com/repos/servo/servo/subscribers","subscription_url":"https://api.github.com/repos/servo/servo/subscription","commits_url":"https://api.github.com/repos/servo/servo/commits{/sha}","git_commits_url":"https://api.github.com/repos/servo/servo/git/commits{/sha}","comments_url":"https://api.github.com/repos/servo/servo/comments{/number}","issue_comment_url":"https://api.github.com/repos/servo/servo/issues/comments{/number}","contents_url":"https://api.github.com/repos/servo/servo/contents/{+path}","compare_url":"https://api.github.com/repos/servo/servo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/servo/servo/merges","archive_url":"https://api.github.com/repos/servo/servo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/servo/servo/downloads","issues_url":"https://api.github.com/repos/servo/servo/issues{/number}","pulls_url":"https://api.github.com/repos/servo/servo/pulls{/number}","milestones_url":"https://api.github.com/repos/servo/servo/milestones{/number}","notifications_url":"https://api.github.com/repos/servo/servo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/servo/servo/labels{/name}","releases_url":"https://api.github.com/repos/servo/servo/releases{/id}","deployments_url":"https://api.github.com/repos/servo/servo/deployments","created_at":"2012-02-08T19:07:25Z","updated_at":"2016-09-21T08:46:45Z","pushed_at":"2016-09-21T14:03:41Z","git_url":"git://github.com/servo/servo.git","ssh_url":"git@github.com:servo/servo.git","clone_url":"https://github.com/servo/servo.git","svn_url":"https://github.com/servo/servo","homepage":"https://servo.org/","size":295878,"stargazers_count":7932,"watchers_count":7932,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1269,"mirror_url":null,"open_issues_count":1733,"forks":1269,"open_issues":1733,"watchers":7932,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/servo/servo/pulls/13345"},"html":{"href":"https://github.com/servo/servo/pull/13345"},"issue":{"href":"https://api.github.com/repos/servo/servo/issues/13345"},"comments":{"href":"https://api.github.com/repos/servo/servo/issues/13345/comments"},"review_comments":{"href":"https://api.github.com/repos/servo/servo/pulls/13345/comments"},"review_comment":{"href":"https://api.github.com/repos/servo/servo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/servo/servo/pulls/13345/commits"},"statuses":{"href":"https://api.github.com/repos/servo/servo/statuses/5087c77eea51019a8471589c957b5bb11f66b5a1"}}}}
{"actor":{"display_login":"jdm"}}