{"action":"created","comment":{"url":"https://api.github.com/repos/thumbor/thumbor/pulls/comments/42743630","id":42743630,"diff_hunk":"@@ -0,0 +1,130 @@\n+#!/usr/bin/python\n+# -*- coding: utf-8 -*-\n+\n+# thumbor imaging service\n+# https://github.com/thumbor/thumbor/wiki\n+\n+# Licensed under the MIT license:\n+# http://www.opensource.org/licenses/mit-license\n+# Copyright (c) 2011 globo.com timehome@corp.globo.com\n+\n+import re\n+import tornado.httpclient\n+from . import LoaderResult\n+from thumbor.utils import logger\n+from datetime import datetime\n+from os import fstat\n+from os.path import join, exists, abspath\n+from urllib import unquote\n+from tornado.concurrent import return_future\n+from urlparse import urlparse\n+from functools import partial\n+\n+@return_future\n+def load(context, path, callback):\n+    file_path = join(context.config.FILE_LOADER_ROOT_PATH.rstrip('/'), unquote(path).lstrip('/'))\n+    file_path = abspath(file_path)\n+    inside_root_path = file_path.startswith(context.config.FILE_LOADER_ROOT_PATH)\n+\n+    result = LoaderResult()\n+\n+    if inside_root_path and exists(file_path):\n+\n+        with open(file_path, 'r') as f:\n+            stats = fstat(f.fileno())\n+\n+            result.successful = True\n+            result.buffer = f.read()\n+\n+            result.metadata.update(\n+                size=stats.st_size,\n+                updated_at=datetime.utcfromtimestamp(stats.st_mtime)\n+            )\n+        callback(result)\n+\n+    elif path.startswith('http') == True:","path":"thumbor/loaders/file_fallback_http_loader.py","position":45,"original_position":45,"commit_id":"1768aed02d35448d494ba4a905afdd7b33b606d2","original_commit_id":"1768aed02d35448d494ba4a905afdd7b33b606d2","user":{"login":"masom","id":438456,"avatar_url":"https://avatars.githubusercontent.com/u/438456?v=3","gravatar_id":"","url":"https://api.github.com/users/masom","html_url":"https://github.com/masom","followers_url":"https://api.github.com/users/masom/followers","following_url":"https://api.github.com/users/masom/following{/other_user}","gists_url":"https://api.github.com/users/masom/gists{/gist_id}","starred_url":"https://api.github.com/users/masom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/masom/subscriptions","organizations_url":"https://api.github.com/users/masom/orgs","repos_url":"https://api.github.com/users/masom/repos","events_url":"https://api.github.com/users/masom/events{/privacy}","received_events_url":"https://api.github.com/users/masom/received_events","type":"User","site_admin":false},"body":"This line can just be `if url.startswith('http'):`","created_at":"2015-10-22T12:53:07Z","updated_at":"2015-10-22T12:53:07Z","html_url":"https://github.com/thumbor/thumbor/pull/584#discussion_r42743630","pull_request_url":"https://api.github.com/repos/thumbor/thumbor/pulls/584","_links":{"self":{"href":"https://api.github.com/repos/thumbor/thumbor/pulls/comments/42743630"},"html":{"href":"https://github.com/thumbor/thumbor/pull/584#discussion_r42743630"},"pull_request":{"href":"https://api.github.com/repos/thumbor/thumbor/pulls/584"}}},"pull_request":{"url":"https://api.github.com/repos/thumbor/thumbor/pulls/584","id":48410457,"html_url":"https://github.com/thumbor/thumbor/pull/584","diff_url":"https://github.com/thumbor/thumbor/pull/584.diff","patch_url":"https://github.com/thumbor/thumbor/pull/584.patch","issue_url":"https://api.github.com/repos/thumbor/thumbor/issues/584","number":584,"state":"open","locked":false,"title":"Loaders","user":{"login":"hhankj2u","id":10140299,"avatar_url":"https://avatars.githubusercontent.com/u/10140299?v=3","gravatar_id":"","url":"https://api.github.com/users/hhankj2u","html_url":"https://github.com/hhankj2u","followers_url":"https://api.github.com/users/hhankj2u/followers","following_url":"https://api.github.com/users/hhankj2u/following{/other_user}","gists_url":"https://api.github.com/users/hhankj2u/gists{/gist_id}","starred_url":"https://api.github.com/users/hhankj2u/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhankj2u/subscriptions","organizations_url":"https://api.github.com/users/hhankj2u/orgs","repos_url":"https://api.github.com/users/hhankj2u/repos","events_url":"https://api.github.com/users/hhankj2u/events{/privacy}","received_events_url":"https://api.github.com/users/hhankj2u/received_events","type":"User","site_admin":false},"body":"I have a problem when using Thumbor with my project.Most images are load from same location of Thumbor. Another images are load from API (in another server). \r\nSo if **/path/to/image.jpg** start with **http**, Thumbor will use http loader otherwise it will use file loader.","created_at":"2015-10-22T02:13:10Z","updated_at":"2015-10-22T12:53:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d2c929cac7577fa71901d1264bc4de902d66476c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/thumbor/thumbor/pulls/584/commits","review_comments_url":"https://api.github.com/repos/thumbor/thumbor/pulls/584/comments","review_comment_url":"https://api.github.com/repos/thumbor/thumbor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/thumbor/thumbor/issues/584/comments","statuses_url":"https://api.github.com/repos/thumbor/thumbor/statuses/1768aed02d35448d494ba4a905afdd7b33b606d2","head":{"label":"hhankj2u:loaders","ref":"loaders","sha":"1768aed02d35448d494ba4a905afdd7b33b606d2","user":{"login":"hhankj2u","id":10140299,"avatar_url":"https://avatars.githubusercontent.com/u/10140299?v=3","gravatar_id":"","url":"https://api.github.com/users/hhankj2u","html_url":"https://github.com/hhankj2u","followers_url":"https://api.github.com/users/hhankj2u/followers","following_url":"https://api.github.com/users/hhankj2u/following{/other_user}","gists_url":"https://api.github.com/users/hhankj2u/gists{/gist_id}","starred_url":"https://api.github.com/users/hhankj2u/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhankj2u/subscriptions","organizations_url":"https://api.github.com/users/hhankj2u/orgs","repos_url":"https://api.github.com/users/hhankj2u/repos","events_url":"https://api.github.com/users/hhankj2u/events{/privacy}","received_events_url":"https://api.github.com/users/hhankj2u/received_events","type":"User","site_admin":false},"repo":{"id":44714634,"name":"thumbor","full_name":"hhankj2u/thumbor","owner":{"login":"hhankj2u","id":10140299,"avatar_url":"https://avatars.githubusercontent.com/u/10140299?v=3","gravatar_id":"","url":"https://api.github.com/users/hhankj2u","html_url":"https://github.com/hhankj2u","followers_url":"https://api.github.com/users/hhankj2u/followers","following_url":"https://api.github.com/users/hhankj2u/following{/other_user}","gists_url":"https://api.github.com/users/hhankj2u/gists{/gist_id}","starred_url":"https://api.github.com/users/hhankj2u/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhankj2u/subscriptions","organizations_url":"https://api.github.com/users/hhankj2u/orgs","repos_url":"https://api.github.com/users/hhankj2u/repos","events_url":"https://api.github.com/users/hhankj2u/events{/privacy}","received_events_url":"https://api.github.com/users/hhankj2u/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hhankj2u/thumbor","description":"thumbor is an open-source photo thumbnail service by globo.com","fork":true,"url":"https://api.github.com/repos/hhankj2u/thumbor","forks_url":"https://api.github.com/repos/hhankj2u/thumbor/forks","keys_url":"https://api.github.com/repos/hhankj2u/thumbor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hhankj2u/thumbor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hhankj2u/thumbor/teams","hooks_url":"https://api.github.com/repos/hhankj2u/thumbor/hooks","issue_events_url":"https://api.github.com/repos/hhankj2u/thumbor/issues/events{/number}","events_url":"https://api.github.com/repos/hhankj2u/thumbor/events","assignees_url":"https://api.github.com/repos/hhankj2u/thumbor/assignees{/user}","branches_url":"https://api.github.com/repos/hhankj2u/thumbor/branches{/branch}","tags_url":"https://api.github.com/repos/hhankj2u/thumbor/tags","blobs_url":"https://api.github.com/repos/hhankj2u/thumbor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hhankj2u/thumbor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hhankj2u/thumbor/git/refs{/sha}","trees_url":"https://api.github.com/repos/hhankj2u/thumbor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hhankj2u/thumbor/statuses/{sha}","languages_url":"https://api.github.com/repos/hhankj2u/thumbor/languages","stargazers_url":"https://api.github.com/repos/hhankj2u/thumbor/stargazers","contributors_url":"https://api.github.com/repos/hhankj2u/thumbor/contributors","subscribers_url":"https://api.github.com/repos/hhankj2u/thumbor/subscribers","subscription_url":"https://api.github.com/repos/hhankj2u/thumbor/subscription","commits_url":"https://api.github.com/repos/hhankj2u/thumbor/commits{/sha}","git_commits_url":"https://api.github.com/repos/hhankj2u/thumbor/git/commits{/sha}","comments_url":"https://api.github.com/repos/hhankj2u/thumbor/comments{/number}","issue_comment_url":"https://api.github.com/repos/hhankj2u/thumbor/issues/comments{/number}","contents_url":"https://api.github.com/repos/hhankj2u/thumbor/contents/{+path}","compare_url":"https://api.github.com/repos/hhankj2u/thumbor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hhankj2u/thumbor/merges","archive_url":"https://api.github.com/repos/hhankj2u/thumbor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hhankj2u/thumbor/downloads","issues_url":"https://api.github.com/repos/hhankj2u/thumbor/issues{/number}","pulls_url":"https://api.github.com/repos/hhankj2u/thumbor/pulls{/number}","milestones_url":"https://api.github.com/repos/hhankj2u/thumbor/milestones{/number}","notifications_url":"https://api.github.com/repos/hhankj2u/thumbor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hhankj2u/thumbor/labels{/name}","releases_url":"https://api.github.com/repos/hhankj2u/thumbor/releases{/id}","created_at":"2015-10-22T01:31:32Z","updated_at":"2015-10-22T01:31:35Z","pushed_at":"2015-10-22T01:52:44Z","git_url":"git://github.com/hhankj2u/thumbor.git","ssh_url":"git@github.com:hhankj2u/thumbor.git","clone_url":"https://github.com/hhankj2u/thumbor.git","svn_url":"https://github.com/hhankj2u/thumbor","homepage":"http://thumbor.org","size":28157,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"thumbor:master","ref":"master","sha":"7b3b7851c5f490fb41e4eb02412712b107829a81","user":{"login":"thumbor","id":6918711,"avatar_url":"https://avatars.githubusercontent.com/u/6918711?v=3","gravatar_id":"","url":"https://api.github.com/users/thumbor","html_url":"https://github.com/thumbor","followers_url":"https://api.github.com/users/thumbor/followers","following_url":"https://api.github.com/users/thumbor/following{/other_user}","gists_url":"https://api.github.com/users/thumbor/gists{/gist_id}","starred_url":"https://api.github.com/users/thumbor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thumbor/subscriptions","organizations_url":"https://api.github.com/users/thumbor/orgs","repos_url":"https://api.github.com/users/thumbor/repos","events_url":"https://api.github.com/users/thumbor/events{/privacy}","received_events_url":"https://api.github.com/users/thumbor/received_events","type":"Organization","site_admin":false},"repo":{"id":1488139,"name":"thumbor","full_name":"thumbor/thumbor","owner":{"login":"thumbor","id":6918711,"avatar_url":"https://avatars.githubusercontent.com/u/6918711?v=3","gravatar_id":"","url":"https://api.github.com/users/thumbor","html_url":"https://github.com/thumbor","followers_url":"https://api.github.com/users/thumbor/followers","following_url":"https://api.github.com/users/thumbor/following{/other_user}","gists_url":"https://api.github.com/users/thumbor/gists{/gist_id}","starred_url":"https://api.github.com/users/thumbor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thumbor/subscriptions","organizations_url":"https://api.github.com/users/thumbor/orgs","repos_url":"https://api.github.com/users/thumbor/repos","events_url":"https://api.github.com/users/thumbor/events{/privacy}","received_events_url":"https://api.github.com/users/thumbor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thumbor/thumbor","description":"thumbor is an open-source photo thumbnail service by globo.com","fork":false,"url":"https://api.github.com/repos/thumbor/thumbor","forks_url":"https://api.github.com/repos/thumbor/thumbor/forks","keys_url":"https://api.github.com/repos/thumbor/thumbor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thumbor/thumbor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thumbor/thumbor/teams","hooks_url":"https://api.github.com/repos/thumbor/thumbor/hooks","issue_events_url":"https://api.github.com/repos/thumbor/thumbor/issues/events{/number}","events_url":"https://api.github.com/repos/thumbor/thumbor/events","assignees_url":"https://api.github.com/repos/thumbor/thumbor/assignees{/user}","branches_url":"https://api.github.com/repos/thumbor/thumbor/branches{/branch}","tags_url":"https://api.github.com/repos/thumbor/thumbor/tags","blobs_url":"https://api.github.com/repos/thumbor/thumbor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thumbor/thumbor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thumbor/thumbor/git/refs{/sha}","trees_url":"https://api.github.com/repos/thumbor/thumbor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thumbor/thumbor/statuses/{sha}","languages_url":"https://api.github.com/repos/thumbor/thumbor/languages","stargazers_url":"https://api.github.com/repos/thumbor/thumbor/stargazers","contributors_url":"https://api.github.com/repos/thumbor/thumbor/contributors","subscribers_url":"https://api.github.com/repos/thumbor/thumbor/subscribers","subscription_url":"https://api.github.com/repos/thumbor/thumbor/subscription","commits_url":"https://api.github.com/repos/thumbor/thumbor/commits{/sha}","git_commits_url":"https://api.github.com/repos/thumbor/thumbor/git/commits{/sha}","comments_url":"https://api.github.com/repos/thumbor/thumbor/comments{/number}","issue_comment_url":"https://api.github.com/repos/thumbor/thumbor/issues/comments{/number}","contents_url":"https://api.github.com/repos/thumbor/thumbor/contents/{+path}","compare_url":"https://api.github.com/repos/thumbor/thumbor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thumbor/thumbor/merges","archive_url":"https://api.github.com/repos/thumbor/thumbor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thumbor/thumbor/downloads","issues_url":"https://api.github.com/repos/thumbor/thumbor/issues{/number}","pulls_url":"https://api.github.com/repos/thumbor/thumbor/pulls{/number}","milestones_url":"https://api.github.com/repos/thumbor/thumbor/milestones{/number}","notifications_url":"https://api.github.com/repos/thumbor/thumbor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thumbor/thumbor/labels{/name}","releases_url":"https://api.github.com/repos/thumbor/thumbor/releases{/id}","created_at":"2011-03-16T17:30:05Z","updated_at":"2015-10-21T19:11:02Z","pushed_at":"2015-10-22T09:51:14Z","git_url":"git://github.com/thumbor/thumbor.git","ssh_url":"git@github.com:thumbor/thumbor.git","clone_url":"https://github.com/thumbor/thumbor.git","svn_url":"https://github.com/thumbor/thumbor","homepage":"http://thumbor.org","size":28157,"stargazers_count":3363,"watchers_count":3363,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":312,"mirror_url":null,"open_issues_count":69,"forks":312,"open_issues":69,"watchers":3363,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/thumbor/thumbor/pulls/584"},"html":{"href":"https://github.com/thumbor/thumbor/pull/584"},"issue":{"href":"https://api.github.com/repos/thumbor/thumbor/issues/584"},"comments":{"href":"https://api.github.com/repos/thumbor/thumbor/issues/584/comments"},"review_comments":{"href":"https://api.github.com/repos/thumbor/thumbor/pulls/584/comments"},"review_comment":{"href":"https://api.github.com/repos/thumbor/thumbor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/thumbor/thumbor/pulls/584/commits"},"statuses":{"href":"https://api.github.com/repos/thumbor/thumbor/statuses/1768aed02d35448d494ba4a905afdd7b33b606d2"}}}}