{"action":"created","comment":{"url":"https://api.github.com/repos/Workiva/w_transport/pulls/comments/68121000","id":68121000,"diff_hunk":"@@ -56,8 +56,14 @@ class HttpBody extends BaseHttpBody {\n   Encoding _encoding;\n \n   /// Construct the body to an HTTP request or an HTTP response from bytes.\n+  ///\n+  /// If an encoding cannot be parsed from the content-type header (via the\n+  /// `charset` param), then [fallbackEncoding] will be used (UTF8 by default).\n   HttpBody.fromBytes(MediaType this.contentType, List<int> bytes,\n-      {Encoding fallbackEncoding}) {\n+      {Encoding fallbackEncoding: UTF8}) {\n+    if (fallbackEncoding == null) {\n+      throw new ArgumentError.notNull('fallbackEncoding');","path":"lib/src/http/http_body.dart","position":11,"original_position":11,"commit_id":"c45b7e6ece37108e9bde0f76cd1dc18262a12a8c","original_commit_id":"c45b7e6ece37108e9bde0f76cd1dc18262a12a8c","user":{"login":"evanweible-wf","id":1738457,"avatar_url":"https://avatars.githubusercontent.com/u/1738457?v=3","gravatar_id":"","url":"https://api.github.com/users/evanweible-wf","html_url":"https://github.com/evanweible-wf","followers_url":"https://api.github.com/users/evanweible-wf/followers","following_url":"https://api.github.com/users/evanweible-wf/following{/other_user}","gists_url":"https://api.github.com/users/evanweible-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/evanweible-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evanweible-wf/subscriptions","organizations_url":"https://api.github.com/users/evanweible-wf/orgs","repos_url":"https://api.github.com/users/evanweible-wf/repos","events_url":"https://api.github.com/users/evanweible-wf/events{/privacy}","received_events_url":"https://api.github.com/users/evanweible-wf/received_events","type":"User","site_admin":false},"body":"Yeah that's better.","created_at":"2016-06-22T19:41:57Z","updated_at":"2016-06-22T19:41:57Z","html_url":"https://github.com/Workiva/w_transport/pull/161#discussion_r68121000","pull_request_url":"https://api.github.com/repos/Workiva/w_transport/pulls/161","_links":{"self":{"href":"https://api.github.com/repos/Workiva/w_transport/pulls/comments/68121000"},"html":{"href":"https://github.com/Workiva/w_transport/pull/161#discussion_r68121000"},"pull_request":{"href":"https://api.github.com/repos/Workiva/w_transport/pulls/161"}}},"pull_request":{"url":"https://api.github.com/repos/Workiva/w_transport/pulls/161","id":74843785,"html_url":"https://github.com/Workiva/w_transport/pull/161","diff_url":"https://github.com/Workiva/w_transport/pull/161.diff","patch_url":"https://github.com/Workiva/w_transport/pull/161.patch","issue_url":"https://api.github.com/repos/Workiva/w_transport/issues/161","number":161,"state":"open","locked":false,"title":"Handle request with no encoding and no charset","user":{"login":"evanweible-wf","id":1738457,"avatar_url":"https://avatars.githubusercontent.com/u/1738457?v=3","gravatar_id":"","url":"https://api.github.com/users/evanweible-wf","html_url":"https://github.com/evanweible-wf","followers_url":"https://api.github.com/users/evanweible-wf/followers","following_url":"https://api.github.com/users/evanweible-wf/following{/other_user}","gists_url":"https://api.github.com/users/evanweible-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/evanweible-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evanweible-wf/subscriptions","organizations_url":"https://api.github.com/users/evanweible-wf/orgs","repos_url":"https://api.github.com/users/evanweible-wf/repos","events_url":"https://api.github.com/users/evanweible-wf/events{/privacy}","received_events_url":"https://api.github.com/users/evanweible-wf/received_events","type":"User","site_admin":false},"body":"_Fixes #159._\r\n\r\n## Issue\r\n#159 reported an issue when setting a request's content-type manually. If that content-type has no `charset` parameter, and the request's encoding was not set, you will hit an RTE in `HttpBody` when trying to read the body and a conversion is required (bytes->string or vice versa). This is because the `HttpBody` constructors have an optional `fallbackEncoding` parameter that has no default value. For responses, we pass in a fallback encoding of `LATIN1` per RFC 2616, but we aren't passing in a fallback encoding at all for request bodies.\r\n\r\nThis issue hadn't manifested itself before because most requests set the content-type automatically, including the charset, but #153 introduced the ability to manually set the content-type.\r\n\r\n## Solution\r\n- Update `HttpBody.fromString()` and `HttpBody.fromBytes()` to give the optional `fallbackEncoding` parameter a default value of `UTF8`.\r\n- Add a null check that will throw an `ArgumentError` if `fallbackEncoding` happens to be null\r\n- Additionally, a null check for encoding was added before trying to read the name in `ResponseFormatException`.\r\n- Bonus: When attempting to decode/encode a request/response body, we now only catch the expected error instead of any exception (ArgumentError for encode, FormatException for decode). This will prevent us from swallowing unexpected exceptions erroneously wrapping them in a `ResponseFormatException`, which is what happened in the stack trace from #159.\r\n\r\n## Testing\r\n- [ ] CI passes\r\n- [ ] HTTP examples work as expected\r\n- [ ] @stevenosborne-wf's tests are fixed\r\n\r\n## Code Review\r\n@trentgrover-wf \r\n@maxwellpeterson-wf \r\n@dustinlessard-wf \r\n@jayudey-wf \r\n@sebastianmalysa-wf \r\n@srinivasdhanwada-wf \r\n\r\nfyi: @stevenosborne-wf ","created_at":"2016-06-22T19:38:05Z","updated_at":"2016-06-22T19:41:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"116385e85676c801ee2c8ccd1bdf5382c1595b36","assignee":null,"milestone":{"url":"https://api.github.com/repos/Workiva/w_transport/milestones/9","html_url":"https://github.com/Workiva/w_transport/milestones/2.6.1","labels_url":"https://api.github.com/repos/Workiva/w_transport/milestones/9/labels","id":1840986,"number":9,"title":"2.6.1","description":"","creator":{"login":"evanweible-wf","id":1738457,"avatar_url":"https://avatars.githubusercontent.com/u/1738457?v=3","gravatar_id":"","url":"https://api.github.com/users/evanweible-wf","html_url":"https://github.com/evanweible-wf","followers_url":"https://api.github.com/users/evanweible-wf/followers","following_url":"https://api.github.com/users/evanweible-wf/following{/other_user}","gists_url":"https://api.github.com/users/evanweible-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/evanweible-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evanweible-wf/subscriptions","organizations_url":"https://api.github.com/users/evanweible-wf/orgs","repos_url":"https://api.github.com/users/evanweible-wf/repos","events_url":"https://api.github.com/users/evanweible-wf/events{/privacy}","received_events_url":"https://api.github.com/users/evanweible-wf/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":1,"state":"open","created_at":"2016-06-21T16:10:11Z","updated_at":"2016-06-22T19:38:14Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/Workiva/w_transport/pulls/161/commits","review_comments_url":"https://api.github.com/repos/Workiva/w_transport/pulls/161/comments","review_comment_url":"https://api.github.com/repos/Workiva/w_transport/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Workiva/w_transport/issues/161/comments","statuses_url":"https://api.github.com/repos/Workiva/w_transport/statuses/c45b7e6ece37108e9bde0f76cd1dc18262a12a8c","head":{"label":"Workiva:default-request-encoding","ref":"default-request-encoding","sha":"c45b7e6ece37108e9bde0f76cd1dc18262a12a8c","user":{"login":"Workiva","id":1087529,"avatar_url":"https://avatars.githubusercontent.com/u/1087529?v=3","gravatar_id":"","url":"https://api.github.com/users/Workiva","html_url":"https://github.com/Workiva","followers_url":"https://api.github.com/users/Workiva/followers","following_url":"https://api.github.com/users/Workiva/following{/other_user}","gists_url":"https://api.github.com/users/Workiva/gists{/gist_id}","starred_url":"https://api.github.com/users/Workiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Workiva/subscriptions","organizations_url":"https://api.github.com/users/Workiva/orgs","repos_url":"https://api.github.com/users/Workiva/repos","events_url":"https://api.github.com/users/Workiva/events{/privacy}","received_events_url":"https://api.github.com/users/Workiva/received_events","type":"Organization","site_admin":false},"repo":{"id":32808289,"name":"w_transport","full_name":"Workiva/w_transport","owner":{"login":"Workiva","id":1087529,"avatar_url":"https://avatars.githubusercontent.com/u/1087529?v=3","gravatar_id":"","url":"https://api.github.com/users/Workiva","html_url":"https://github.com/Workiva","followers_url":"https://api.github.com/users/Workiva/followers","following_url":"https://api.github.com/users/Workiva/following{/other_user}","gists_url":"https://api.github.com/users/Workiva/gists{/gist_id}","starred_url":"https://api.github.com/users/Workiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Workiva/subscriptions","organizations_url":"https://api.github.com/users/Workiva/orgs","repos_url":"https://api.github.com/users/Workiva/repos","events_url":"https://api.github.com/users/Workiva/events{/privacy}","received_events_url":"https://api.github.com/users/Workiva/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Workiva/w_transport","description":"","fork":false,"url":"https://api.github.com/repos/Workiva/w_transport","forks_url":"https://api.github.com/repos/Workiva/w_transport/forks","keys_url":"https://api.github.com/repos/Workiva/w_transport/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Workiva/w_transport/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Workiva/w_transport/teams","hooks_url":"https://api.github.com/repos/Workiva/w_transport/hooks","issue_events_url":"https://api.github.com/repos/Workiva/w_transport/issues/events{/number}","events_url":"https://api.github.com/repos/Workiva/w_transport/events","assignees_url":"https://api.github.com/repos/Workiva/w_transport/assignees{/user}","branches_url":"https://api.github.com/repos/Workiva/w_transport/branches{/branch}","tags_url":"https://api.github.com/repos/Workiva/w_transport/tags","blobs_url":"https://api.github.com/repos/Workiva/w_transport/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Workiva/w_transport/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Workiva/w_transport/git/refs{/sha}","trees_url":"https://api.github.com/repos/Workiva/w_transport/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Workiva/w_transport/statuses/{sha}","languages_url":"https://api.github.com/repos/Workiva/w_transport/languages","stargazers_url":"https://api.github.com/repos/Workiva/w_transport/stargazers","contributors_url":"https://api.github.com/repos/Workiva/w_transport/contributors","subscribers_url":"https://api.github.com/repos/Workiva/w_transport/subscribers","subscription_url":"https://api.github.com/repos/Workiva/w_transport/subscription","commits_url":"https://api.github.com/repos/Workiva/w_transport/commits{/sha}","git_commits_url":"https://api.github.com/repos/Workiva/w_transport/git/commits{/sha}","comments_url":"https://api.github.com/repos/Workiva/w_transport/comments{/number}","issue_comment_url":"https://api.github.com/repos/Workiva/w_transport/issues/comments{/number}","contents_url":"https://api.github.com/repos/Workiva/w_transport/contents/{+path}","compare_url":"https://api.github.com/repos/Workiva/w_transport/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Workiva/w_transport/merges","archive_url":"https://api.github.com/repos/Workiva/w_transport/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Workiva/w_transport/downloads","issues_url":"https://api.github.com/repos/Workiva/w_transport/issues{/number}","pulls_url":"https://api.github.com/repos/Workiva/w_transport/pulls{/number}","milestones_url":"https://api.github.com/repos/Workiva/w_transport/milestones{/number}","notifications_url":"https://api.github.com/repos/Workiva/w_transport/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Workiva/w_transport/labels{/name}","releases_url":"https://api.github.com/repos/Workiva/w_transport/releases{/id}","deployments_url":"https://api.github.com/repos/Workiva/w_transport/deployments","created_at":"2015-03-24T15:43:40Z","updated_at":"2016-05-02T15:49:19Z","pushed_at":"2016-06-22T19:38:06Z","git_url":"git://github.com/Workiva/w_transport.git","ssh_url":"git@github.com:Workiva/w_transport.git","clone_url":"https://github.com/Workiva/w_transport.git","svn_url":"https://github.com/Workiva/w_transport","homepage":null,"size":858,"stargazers_count":7,"watchers_count":7,"language":"Dart","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":16,"forks":5,"open_issues":16,"watchers":7,"default_branch":"master"}},"base":{"label":"Workiva:master","ref":"master","sha":"ec30c7fd51e841fba5fb069dfa8915ce34f08262","user":{"login":"Workiva","id":1087529,"avatar_url":"https://avatars.githubusercontent.com/u/1087529?v=3","gravatar_id":"","url":"https://api.github.com/users/Workiva","html_url":"https://github.com/Workiva","followers_url":"https://api.github.com/users/Workiva/followers","following_url":"https://api.github.com/users/Workiva/following{/other_user}","gists_url":"https://api.github.com/users/Workiva/gists{/gist_id}","starred_url":"https://api.github.com/users/Workiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Workiva/subscriptions","organizations_url":"https://api.github.com/users/Workiva/orgs","repos_url":"https://api.github.com/users/Workiva/repos","events_url":"https://api.github.com/users/Workiva/events{/privacy}","received_events_url":"https://api.github.com/users/Workiva/received_events","type":"Organization","site_admin":false},"repo":{"id":32808289,"name":"w_transport","full_name":"Workiva/w_transport","owner":{"login":"Workiva","id":1087529,"avatar_url":"https://avatars.githubusercontent.com/u/1087529?v=3","gravatar_id":"","url":"https://api.github.com/users/Workiva","html_url":"https://github.com/Workiva","followers_url":"https://api.github.com/users/Workiva/followers","following_url":"https://api.github.com/users/Workiva/following{/other_user}","gists_url":"https://api.github.com/users/Workiva/gists{/gist_id}","starred_url":"https://api.github.com/users/Workiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Workiva/subscriptions","organizations_url":"https://api.github.com/users/Workiva/orgs","repos_url":"https://api.github.com/users/Workiva/repos","events_url":"https://api.github.com/users/Workiva/events{/privacy}","received_events_url":"https://api.github.com/users/Workiva/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Workiva/w_transport","description":"","fork":false,"url":"https://api.github.com/repos/Workiva/w_transport","forks_url":"https://api.github.com/repos/Workiva/w_transport/forks","keys_url":"https://api.github.com/repos/Workiva/w_transport/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Workiva/w_transport/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Workiva/w_transport/teams","hooks_url":"https://api.github.com/repos/Workiva/w_transport/hooks","issue_events_url":"https://api.github.com/repos/Workiva/w_transport/issues/events{/number}","events_url":"https://api.github.com/repos/Workiva/w_transport/events","assignees_url":"https://api.github.com/repos/Workiva/w_transport/assignees{/user}","branches_url":"https://api.github.com/repos/Workiva/w_transport/branches{/branch}","tags_url":"https://api.github.com/repos/Workiva/w_transport/tags","blobs_url":"https://api.github.com/repos/Workiva/w_transport/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Workiva/w_transport/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Workiva/w_transport/git/refs{/sha}","trees_url":"https://api.github.com/repos/Workiva/w_transport/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Workiva/w_transport/statuses/{sha}","languages_url":"https://api.github.com/repos/Workiva/w_transport/languages","stargazers_url":"https://api.github.com/repos/Workiva/w_transport/stargazers","contributors_url":"https://api.github.com/repos/Workiva/w_transport/contributors","subscribers_url":"https://api.github.com/repos/Workiva/w_transport/subscribers","subscription_url":"https://api.github.com/repos/Workiva/w_transport/subscription","commits_url":"https://api.github.com/repos/Workiva/w_transport/commits{/sha}","git_commits_url":"https://api.github.com/repos/Workiva/w_transport/git/commits{/sha}","comments_url":"https://api.github.com/repos/Workiva/w_transport/comments{/number}","issue_comment_url":"https://api.github.com/repos/Workiva/w_transport/issues/comments{/number}","contents_url":"https://api.github.com/repos/Workiva/w_transport/contents/{+path}","compare_url":"https://api.github.com/repos/Workiva/w_transport/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Workiva/w_transport/merges","archive_url":"https://api.github.com/repos/Workiva/w_transport/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Workiva/w_transport/downloads","issues_url":"https://api.github.com/repos/Workiva/w_transport/issues{/number}","pulls_url":"https://api.github.com/repos/Workiva/w_transport/pulls{/number}","milestones_url":"https://api.github.com/repos/Workiva/w_transport/milestones{/number}","notifications_url":"https://api.github.com/repos/Workiva/w_transport/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Workiva/w_transport/labels{/name}","releases_url":"https://api.github.com/repos/Workiva/w_transport/releases{/id}","deployments_url":"https://api.github.com/repos/Workiva/w_transport/deployments","created_at":"2015-03-24T15:43:40Z","updated_at":"2016-05-02T15:49:19Z","pushed_at":"2016-06-22T19:38:06Z","git_url":"git://github.com/Workiva/w_transport.git","ssh_url":"git@github.com:Workiva/w_transport.git","clone_url":"https://github.com/Workiva/w_transport.git","svn_url":"https://github.com/Workiva/w_transport","homepage":null,"size":858,"stargazers_count":7,"watchers_count":7,"language":"Dart","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":16,"forks":5,"open_issues":16,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Workiva/w_transport/pulls/161"},"html":{"href":"https://github.com/Workiva/w_transport/pull/161"},"issue":{"href":"https://api.github.com/repos/Workiva/w_transport/issues/161"},"comments":{"href":"https://api.github.com/repos/Workiva/w_transport/issues/161/comments"},"review_comments":{"href":"https://api.github.com/repos/Workiva/w_transport/pulls/161/comments"},"review_comment":{"href":"https://api.github.com/repos/Workiva/w_transport/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Workiva/w_transport/pulls/161/commits"},"statuses":{"href":"https://api.github.com/repos/Workiva/w_transport/statuses/c45b7e6ece37108e9bde0f76cd1dc18262a12a8c"}}}}
{"actor":{"display_login":"evanweible-wf"}}