{"action":"opened","number":208,"pull_request":{"url":"https://api.github.com/repos/Alamofire/AlamofireImage/pulls/208","id":89885675,"html_url":"https://github.com/Alamofire/AlamofireImage/pull/208","diff_url":"https://github.com/Alamofire/AlamofireImage/pull/208.diff","patch_url":"https://github.com/Alamofire/AlamofireImage/pull/208.patch","issue_url":"https://api.github.com/repos/Alamofire/AlamofireImage/issues/208","number":208,"state":"open","locked":false,"title":"Support for custom imageResponseSerializer","user":{"login":"tapz","id":11726387,"avatar_url":"https://avatars.githubusercontent.com/u/11726387?v=3","gravatar_id":"","url":"https://api.github.com/users/tapz","html_url":"https://github.com/tapz","followers_url":"https://api.github.com/users/tapz/followers","following_url":"https://api.github.com/users/tapz/following{/other_user}","gists_url":"https://api.github.com/users/tapz/gists{/gist_id}","starred_url":"https://api.github.com/users/tapz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tapz/subscriptions","organizations_url":"https://api.github.com/users/tapz/orgs","repos_url":"https://api.github.com/users/tapz/repos","events_url":"https://api.github.com/users/tapz/events{/privacy}","received_events_url":"https://api.github.com/users/tapz/received_events","type":"User","site_admin":false},"body":"I made as minimal changes as possible to add a way to replace the default `imageResponseSerializer` in `ImageDownloader`. I added `imageResponseSerializer` variable in `ImageDownloader` instead of calling `DataRequest.imageResponseSerializer()` directly to make it possible to use a custom serializer implementation.\r\n\r\n`validateContentType` needs to be public to be accessible from the custom `ImageResponseSerializer` implementation (using AlamofireImage as a pod).\r\n\r\nWith these changes I was able to create my own `ImageResponseSerializer` closure and add animated GIF support to my app. Below is my custom serializer code. `imageWithCachedData` extracts frames from the gif data.\r\n\r\n```\r\nlet downloader = ImageDownloader(maximumActiveDownloads: 10)\r\n\r\ndownloader.imageResponseSerializer = DataResponseSerializer { request, response, data, error in\r\n    let result = Request.serializeResponseData(response: response, data: data, error: error)\r\n    guard case let .success(data) = result else { return .failure(result.error!) }\r\n\r\n    do {\r\n        try DataRequest.validateContentType(for: request, response: response)\r\n        \r\n        if let image = UIImage.imageWithCachedData(data) {\r\n            image.af_inflate()\r\n            return .success(image)\r\n        }\r\n\r\n        return .failure(AFIError.imageSerializationFailed)\r\n    } catch {\r\n        return .failure(error)\r\n    }\r\n}\r\n\r\nUIImageView.af_sharedImageDownloader = downloader\r\n```","created_at":"2016-10-18T19:48:07Z","updated_at":"2016-10-18T19:48:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"840185637682e29253e80e98e5e471a1514a52ed","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Alamofire/AlamofireImage/pulls/208/commits","review_comments_url":"https://api.github.com/repos/Alamofire/AlamofireImage/pulls/208/comments","review_comment_url":"https://api.github.com/repos/Alamofire/AlamofireImage/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Alamofire/AlamofireImage/issues/208/comments","statuses_url":"https://api.github.com/repos/Alamofire/AlamofireImage/statuses/8390ff5e46e24256476d7cd06d728a69f5ccfa45","head":{"label":"tapz:master","ref":"master","sha":"8390ff5e46e24256476d7cd06d728a69f5ccfa45","user":{"login":"tapz","id":11726387,"avatar_url":"https://avatars.githubusercontent.com/u/11726387?v=3","gravatar_id":"","url":"https://api.github.com/users/tapz","html_url":"https://github.com/tapz","followers_url":"https://api.github.com/users/tapz/followers","following_url":"https://api.github.com/users/tapz/following{/other_user}","gists_url":"https://api.github.com/users/tapz/gists{/gist_id}","starred_url":"https://api.github.com/users/tapz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tapz/subscriptions","organizations_url":"https://api.github.com/users/tapz/orgs","repos_url":"https://api.github.com/users/tapz/repos","events_url":"https://api.github.com/users/tapz/events{/privacy}","received_events_url":"https://api.github.com/users/tapz/received_events","type":"User","site_admin":false},"repo":{"id":71159424,"name":"AlamofireImage","full_name":"tapz/AlamofireImage","owner":{"login":"tapz","id":11726387,"avatar_url":"https://avatars.githubusercontent.com/u/11726387?v=3","gravatar_id":"","url":"https://api.github.com/users/tapz","html_url":"https://github.com/tapz","followers_url":"https://api.github.com/users/tapz/followers","following_url":"https://api.github.com/users/tapz/following{/other_user}","gists_url":"https://api.github.com/users/tapz/gists{/gist_id}","starred_url":"https://api.github.com/users/tapz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tapz/subscriptions","organizations_url":"https://api.github.com/users/tapz/orgs","repos_url":"https://api.github.com/users/tapz/repos","events_url":"https://api.github.com/users/tapz/events{/privacy}","received_events_url":"https://api.github.com/users/tapz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tapz/AlamofireImage","description":"AlamofireImage is an image component library for Alamofire","fork":true,"url":"https://api.github.com/repos/tapz/AlamofireImage","forks_url":"https://api.github.com/repos/tapz/AlamofireImage/forks","keys_url":"https://api.github.com/repos/tapz/AlamofireImage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tapz/AlamofireImage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tapz/AlamofireImage/teams","hooks_url":"https://api.github.com/repos/tapz/AlamofireImage/hooks","issue_events_url":"https://api.github.com/repos/tapz/AlamofireImage/issues/events{/number}","events_url":"https://api.github.com/repos/tapz/AlamofireImage/events","assignees_url":"https://api.github.com/repos/tapz/AlamofireImage/assignees{/user}","branches_url":"https://api.github.com/repos/tapz/AlamofireImage/branches{/branch}","tags_url":"https://api.github.com/repos/tapz/AlamofireImage/tags","blobs_url":"https://api.github.com/repos/tapz/AlamofireImage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tapz/AlamofireImage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tapz/AlamofireImage/git/refs{/sha}","trees_url":"https://api.github.com/repos/tapz/AlamofireImage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tapz/AlamofireImage/statuses/{sha}","languages_url":"https://api.github.com/repos/tapz/AlamofireImage/languages","stargazers_url":"https://api.github.com/repos/tapz/AlamofireImage/stargazers","contributors_url":"https://api.github.com/repos/tapz/AlamofireImage/contributors","subscribers_url":"https://api.github.com/repos/tapz/AlamofireImage/subscribers","subscription_url":"https://api.github.com/repos/tapz/AlamofireImage/subscription","commits_url":"https://api.github.com/repos/tapz/AlamofireImage/commits{/sha}","git_commits_url":"https://api.github.com/repos/tapz/AlamofireImage/git/commits{/sha}","comments_url":"https://api.github.com/repos/tapz/AlamofireImage/comments{/number}","issue_comment_url":"https://api.github.com/repos/tapz/AlamofireImage/issues/comments{/number}","contents_url":"https://api.github.com/repos/tapz/AlamofireImage/contents/{+path}","compare_url":"https://api.github.com/repos/tapz/AlamofireImage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tapz/AlamofireImage/merges","archive_url":"https://api.github.com/repos/tapz/AlamofireImage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tapz/AlamofireImage/downloads","issues_url":"https://api.github.com/repos/tapz/AlamofireImage/issues{/number}","pulls_url":"https://api.github.com/repos/tapz/AlamofireImage/pulls{/number}","milestones_url":"https://api.github.com/repos/tapz/AlamofireImage/milestones{/number}","notifications_url":"https://api.github.com/repos/tapz/AlamofireImage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tapz/AlamofireImage/labels{/name}","releases_url":"https://api.github.com/repos/tapz/AlamofireImage/releases{/id}","deployments_url":"https://api.github.com/repos/tapz/AlamofireImage/deployments","created_at":"2016-10-17T16:37:04Z","updated_at":"2016-10-17T16:37:05Z","pushed_at":"2016-10-18T19:36:39Z","git_url":"git://github.com/tapz/AlamofireImage.git","ssh_url":"git@github.com:tapz/AlamofireImage.git","clone_url":"https://github.com/tapz/AlamofireImage.git","svn_url":"https://github.com/tapz/AlamofireImage","homepage":"","size":10107,"stargazers_count":0,"watchers_count":0,"language":"Swift","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":"Alamofire:master","ref":"master","sha":"56ef5158b79a14243e9bbd2016b6d5c529a27074","user":{"login":"Alamofire","id":7774181,"avatar_url":"https://avatars.githubusercontent.com/u/7774181?v=3","gravatar_id":"","url":"https://api.github.com/users/Alamofire","html_url":"https://github.com/Alamofire","followers_url":"https://api.github.com/users/Alamofire/followers","following_url":"https://api.github.com/users/Alamofire/following{/other_user}","gists_url":"https://api.github.com/users/Alamofire/gists{/gist_id}","starred_url":"https://api.github.com/users/Alamofire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alamofire/subscriptions","organizations_url":"https://api.github.com/users/Alamofire/orgs","repos_url":"https://api.github.com/users/Alamofire/repos","events_url":"https://api.github.com/users/Alamofire/events{/privacy}","received_events_url":"https://api.github.com/users/Alamofire/received_events","type":"Organization","site_admin":false},"repo":{"id":41780199,"name":"AlamofireImage","full_name":"Alamofire/AlamofireImage","owner":{"login":"Alamofire","id":7774181,"avatar_url":"https://avatars.githubusercontent.com/u/7774181?v=3","gravatar_id":"","url":"https://api.github.com/users/Alamofire","html_url":"https://github.com/Alamofire","followers_url":"https://api.github.com/users/Alamofire/followers","following_url":"https://api.github.com/users/Alamofire/following{/other_user}","gists_url":"https://api.github.com/users/Alamofire/gists{/gist_id}","starred_url":"https://api.github.com/users/Alamofire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alamofire/subscriptions","organizations_url":"https://api.github.com/users/Alamofire/orgs","repos_url":"https://api.github.com/users/Alamofire/repos","events_url":"https://api.github.com/users/Alamofire/events{/privacy}","received_events_url":"https://api.github.com/users/Alamofire/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Alamofire/AlamofireImage","description":"AlamofireImage is an image component library for Alamofire","fork":false,"url":"https://api.github.com/repos/Alamofire/AlamofireImage","forks_url":"https://api.github.com/repos/Alamofire/AlamofireImage/forks","keys_url":"https://api.github.com/repos/Alamofire/AlamofireImage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Alamofire/AlamofireImage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Alamofire/AlamofireImage/teams","hooks_url":"https://api.github.com/repos/Alamofire/AlamofireImage/hooks","issue_events_url":"https://api.github.com/repos/Alamofire/AlamofireImage/issues/events{/number}","events_url":"https://api.github.com/repos/Alamofire/AlamofireImage/events","assignees_url":"https://api.github.com/repos/Alamofire/AlamofireImage/assignees{/user}","branches_url":"https://api.github.com/repos/Alamofire/AlamofireImage/branches{/branch}","tags_url":"https://api.github.com/repos/Alamofire/AlamofireImage/tags","blobs_url":"https://api.github.com/repos/Alamofire/AlamofireImage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Alamofire/AlamofireImage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Alamofire/AlamofireImage/git/refs{/sha}","trees_url":"https://api.github.com/repos/Alamofire/AlamofireImage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Alamofire/AlamofireImage/statuses/{sha}","languages_url":"https://api.github.com/repos/Alamofire/AlamofireImage/languages","stargazers_url":"https://api.github.com/repos/Alamofire/AlamofireImage/stargazers","contributors_url":"https://api.github.com/repos/Alamofire/AlamofireImage/contributors","subscribers_url":"https://api.github.com/repos/Alamofire/AlamofireImage/subscribers","subscription_url":"https://api.github.com/repos/Alamofire/AlamofireImage/subscription","commits_url":"https://api.github.com/repos/Alamofire/AlamofireImage/commits{/sha}","git_commits_url":"https://api.github.com/repos/Alamofire/AlamofireImage/git/commits{/sha}","comments_url":"https://api.github.com/repos/Alamofire/AlamofireImage/comments{/number}","issue_comment_url":"https://api.github.com/repos/Alamofire/AlamofireImage/issues/comments{/number}","contents_url":"https://api.github.com/repos/Alamofire/AlamofireImage/contents/{+path}","compare_url":"https://api.github.com/repos/Alamofire/AlamofireImage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Alamofire/AlamofireImage/merges","archive_url":"https://api.github.com/repos/Alamofire/AlamofireImage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Alamofire/AlamofireImage/downloads","issues_url":"https://api.github.com/repos/Alamofire/AlamofireImage/issues{/number}","pulls_url":"https://api.github.com/repos/Alamofire/AlamofireImage/pulls{/number}","milestones_url":"https://api.github.com/repos/Alamofire/AlamofireImage/milestones{/number}","notifications_url":"https://api.github.com/repos/Alamofire/AlamofireImage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Alamofire/AlamofireImage/labels{/name}","releases_url":"https://api.github.com/repos/Alamofire/AlamofireImage/releases{/id}","deployments_url":"https://api.github.com/repos/Alamofire/AlamofireImage/deployments","created_at":"2015-09-02T04:40:02Z","updated_at":"2016-10-18T18:53:02Z","pushed_at":"2016-10-18T19:48:07Z","git_url":"git://github.com/Alamofire/AlamofireImage.git","ssh_url":"git@github.com:Alamofire/AlamofireImage.git","clone_url":"https://github.com/Alamofire/AlamofireImage.git","svn_url":"https://github.com/Alamofire/AlamofireImage","homepage":"","size":10107,"stargazers_count":1934,"watchers_count":1934,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":250,"mirror_url":null,"open_issues_count":6,"forks":250,"open_issues":6,"watchers":1934,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Alamofire/AlamofireImage/pulls/208"},"html":{"href":"https://github.com/Alamofire/AlamofireImage/pull/208"},"issue":{"href":"https://api.github.com/repos/Alamofire/AlamofireImage/issues/208"},"comments":{"href":"https://api.github.com/repos/Alamofire/AlamofireImage/issues/208/comments"},"review_comments":{"href":"https://api.github.com/repos/Alamofire/AlamofireImage/pulls/208/comments"},"review_comment":{"href":"https://api.github.com/repos/Alamofire/AlamofireImage/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Alamofire/AlamofireImage/pulls/208/commits"},"statuses":{"href":"https://api.github.com/repos/Alamofire/AlamofireImage/statuses/8390ff5e46e24256476d7cd06d728a69f5ccfa45"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":5,"deletions":2,"changed_files":2}}
{"actor":{"display_login":"tapz"}}