{"action":"created","comment":{"url":"https://api.github.com/repos/scrapy/scrapy/pulls/comments/83602202","pull_request_review_id":4434250,"id":83602202,"diff_hunk":"@@ -0,0 +1,46 @@\n+\"\"\"\n+HTTP basic auth downloader middleware\n+\n+See documentation in docs/topics/downloader-middleware.rst\n+\"\"\"\n+\n+from w3lib.http import basic_auth_header\n+\n+from scrapy import signals\n+\n+from six.moves.urllib.parse import urlparse\n+\n+\n+class AuthMiddleware(object):\n+    \"\"\"Set Basic HTTP Authorization header\n+    (http_user and http_pass spider class attributes)\"\"\"\n+\n+    @classmethod\n+    def from_crawler(cls, crawler):\n+        o = cls()\n+        crawler.signals.connect(o.spider_opened, signal=signals.spider_opened)\n+        return o\n+\n+    def spider_opened(self, spider):\n+        usr = getattr(spider, 'http_user', '')\n+        pwd = getattr(spider, 'http_pass', '')\n+        if usr or pwd:\n+            self.auth = basic_auth_header(usr, pwd)\n+\n+    def process_request(self, request, spider):\n+        auth = getattr(self, 'auth', None)\n+        if auth and 'Authorization' not in request.headers:\n+            request.headers['Authorization'] = auth\n+\n+        # credentials from url are supposed to override spider settings\n+        url = urlparse(request.url)","path":"scrapy/downloadermiddlewares/auth.py","position":36,"original_position":36,"commit_id":"2891e02bcb85bf61738f9f3b24ab6fcf2d9c134a","original_commit_id":"2891e02bcb85bf61738f9f3b24ab6fcf2d9c134a","user":{"login":"redapple","id":886296,"avatar_url":"https://avatars.githubusercontent.com/u/886296?v=3","gravatar_id":"","url":"https://api.github.com/users/redapple","html_url":"https://github.com/redapple","followers_url":"https://api.github.com/users/redapple/followers","following_url":"https://api.github.com/users/redapple/following{/other_user}","gists_url":"https://api.github.com/users/redapple/gists{/gist_id}","starred_url":"https://api.github.com/users/redapple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redapple/subscriptions","organizations_url":"https://api.github.com/users/redapple/orgs","repos_url":"https://api.github.com/users/redapple/repos","events_url":"https://api.github.com/users/redapple/events{/privacy}","received_events_url":"https://api.github.com/users/redapple/received_events","type":"User","site_admin":false},"body":"can `scrapy.utils.httpobj.urlparse_cached` be used here?","created_at":"2016-10-17T09:04:04Z","updated_at":"2016-10-17T09:04:04Z","html_url":"https://github.com/scrapy/scrapy/pull/1466#discussion_r83602202","pull_request_url":"https://api.github.com/repos/scrapy/scrapy/pulls/1466","_links":{"self":{"href":"https://api.github.com/repos/scrapy/scrapy/pulls/comments/83602202"},"html":{"href":"https://github.com/scrapy/scrapy/pull/1466#discussion_r83602202"},"pull_request":{"href":"https://api.github.com/repos/scrapy/scrapy/pulls/1466"}}},"pull_request":{"url":"https://api.github.com/repos/scrapy/scrapy/pulls/1466","id":43698707,"html_url":"https://github.com/scrapy/scrapy/pull/1466","diff_url":"https://github.com/scrapy/scrapy/pull/1466.diff","patch_url":"https://github.com/scrapy/scrapy/pull/1466.patch","issue_url":"https://api.github.com/repos/scrapy/scrapy/issues/1466","number":1466,"state":"open","locked":false,"title":"[MRG+1] Fix for #669","user":{"login":"umrashrf","id":652326,"avatar_url":"https://avatars.githubusercontent.com/u/652326?v=3","gravatar_id":"","url":"https://api.github.com/users/umrashrf","html_url":"https://github.com/umrashrf","followers_url":"https://api.github.com/users/umrashrf/followers","following_url":"https://api.github.com/users/umrashrf/following{/other_user}","gists_url":"https://api.github.com/users/umrashrf/gists{/gist_id}","starred_url":"https://api.github.com/users/umrashrf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/umrashrf/subscriptions","organizations_url":"https://api.github.com/users/umrashrf/orgs","repos_url":"https://api.github.com/users/umrashrf/repos","events_url":"https://api.github.com/users/umrashrf/events{/privacy}","received_events_url":"https://api.github.com/users/umrashrf/received_events","type":"User","site_admin":false},"body":"Solution provided by @dangra https://github.com/scrapy/scrapy/pull/670#issuecomment-38921769\r\n\r\nI can add tests but should I add this dependency for FTP tests? https://github.com/giampaolo/pyftpdlib \r\n\r\nCurrent FTP tests uses Twisted so I'm afraid they won't work for PY3 https://github.com/scrapy/scrapy/blob/master/tests/test_downloader_handlers.py#L523-L543","created_at":"2015-08-29T17:48:23Z","updated_at":"2016-10-17T09:04:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d3298687bef794462283b24c92b00bc51b0adbfe","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/scrapy/scrapy/pulls/1466/commits","review_comments_url":"https://api.github.com/repos/scrapy/scrapy/pulls/1466/comments","review_comment_url":"https://api.github.com/repos/scrapy/scrapy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scrapy/scrapy/issues/1466/comments","statuses_url":"https://api.github.com/repos/scrapy/scrapy/statuses/2891e02bcb85bf61738f9f3b24ab6fcf2d9c134a","head":{"label":"umrashrf:auth-creds-from-url","ref":"auth-creds-from-url","sha":"2891e02bcb85bf61738f9f3b24ab6fcf2d9c134a","user":{"login":"umrashrf","id":652326,"avatar_url":"https://avatars.githubusercontent.com/u/652326?v=3","gravatar_id":"","url":"https://api.github.com/users/umrashrf","html_url":"https://github.com/umrashrf","followers_url":"https://api.github.com/users/umrashrf/followers","following_url":"https://api.github.com/users/umrashrf/following{/other_user}","gists_url":"https://api.github.com/users/umrashrf/gists{/gist_id}","starred_url":"https://api.github.com/users/umrashrf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/umrashrf/subscriptions","organizations_url":"https://api.github.com/users/umrashrf/orgs","repos_url":"https://api.github.com/users/umrashrf/repos","events_url":"https://api.github.com/users/umrashrf/events{/privacy}","received_events_url":"https://api.github.com/users/umrashrf/received_events","type":"User","site_admin":false},"repo":{"id":10407041,"name":"scrapy","full_name":"umrashrf/scrapy","owner":{"login":"umrashrf","id":652326,"avatar_url":"https://avatars.githubusercontent.com/u/652326?v=3","gravatar_id":"","url":"https://api.github.com/users/umrashrf","html_url":"https://github.com/umrashrf","followers_url":"https://api.github.com/users/umrashrf/followers","following_url":"https://api.github.com/users/umrashrf/following{/other_user}","gists_url":"https://api.github.com/users/umrashrf/gists{/gist_id}","starred_url":"https://api.github.com/users/umrashrf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/umrashrf/subscriptions","organizations_url":"https://api.github.com/users/umrashrf/orgs","repos_url":"https://api.github.com/users/umrashrf/repos","events_url":"https://api.github.com/users/umrashrf/events{/privacy}","received_events_url":"https://api.github.com/users/umrashrf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/umrashrf/scrapy","description":"Scrapy, a fast high-level screen scraping and web crawling framework for Python.","fork":true,"url":"https://api.github.com/repos/umrashrf/scrapy","forks_url":"https://api.github.com/repos/umrashrf/scrapy/forks","keys_url":"https://api.github.com/repos/umrashrf/scrapy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/umrashrf/scrapy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/umrashrf/scrapy/teams","hooks_url":"https://api.github.com/repos/umrashrf/scrapy/hooks","issue_events_url":"https://api.github.com/repos/umrashrf/scrapy/issues/events{/number}","events_url":"https://api.github.com/repos/umrashrf/scrapy/events","assignees_url":"https://api.github.com/repos/umrashrf/scrapy/assignees{/user}","branches_url":"https://api.github.com/repos/umrashrf/scrapy/branches{/branch}","tags_url":"https://api.github.com/repos/umrashrf/scrapy/tags","blobs_url":"https://api.github.com/repos/umrashrf/scrapy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/umrashrf/scrapy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/umrashrf/scrapy/git/refs{/sha}","trees_url":"https://api.github.com/repos/umrashrf/scrapy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/umrashrf/scrapy/statuses/{sha}","languages_url":"https://api.github.com/repos/umrashrf/scrapy/languages","stargazers_url":"https://api.github.com/repos/umrashrf/scrapy/stargazers","contributors_url":"https://api.github.com/repos/umrashrf/scrapy/contributors","subscribers_url":"https://api.github.com/repos/umrashrf/scrapy/subscribers","subscription_url":"https://api.github.com/repos/umrashrf/scrapy/subscription","commits_url":"https://api.github.com/repos/umrashrf/scrapy/commits{/sha}","git_commits_url":"https://api.github.com/repos/umrashrf/scrapy/git/commits{/sha}","comments_url":"https://api.github.com/repos/umrashrf/scrapy/comments{/number}","issue_comment_url":"https://api.github.com/repos/umrashrf/scrapy/issues/comments{/number}","contents_url":"https://api.github.com/repos/umrashrf/scrapy/contents/{+path}","compare_url":"https://api.github.com/repos/umrashrf/scrapy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/umrashrf/scrapy/merges","archive_url":"https://api.github.com/repos/umrashrf/scrapy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/umrashrf/scrapy/downloads","issues_url":"https://api.github.com/repos/umrashrf/scrapy/issues{/number}","pulls_url":"https://api.github.com/repos/umrashrf/scrapy/pulls{/number}","milestones_url":"https://api.github.com/repos/umrashrf/scrapy/milestones{/number}","notifications_url":"https://api.github.com/repos/umrashrf/scrapy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/umrashrf/scrapy/labels{/name}","releases_url":"https://api.github.com/repos/umrashrf/scrapy/releases{/id}","deployments_url":"https://api.github.com/repos/umrashrf/scrapy/deployments","created_at":"2013-05-31T14:56:47Z","updated_at":"2016-10-12T04:15:06Z","pushed_at":"2016-06-03T22:06:52Z","git_url":"git://github.com/umrashrf/scrapy.git","ssh_url":"git@github.com:umrashrf/scrapy.git","clone_url":"https://github.com/umrashrf/scrapy.git","svn_url":"https://github.com/umrashrf/scrapy","homepage":"http://scrapy.org","size":14304,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"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":"scrapy:master","ref":"master","sha":"d3ced85ec350e8c195760a8ce975a18ca42f29a0","user":{"login":"scrapy","id":733635,"avatar_url":"https://avatars.githubusercontent.com/u/733635?v=3","gravatar_id":"","url":"https://api.github.com/users/scrapy","html_url":"https://github.com/scrapy","followers_url":"https://api.github.com/users/scrapy/followers","following_url":"https://api.github.com/users/scrapy/following{/other_user}","gists_url":"https://api.github.com/users/scrapy/gists{/gist_id}","starred_url":"https://api.github.com/users/scrapy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scrapy/subscriptions","organizations_url":"https://api.github.com/users/scrapy/orgs","repos_url":"https://api.github.com/users/scrapy/repos","events_url":"https://api.github.com/users/scrapy/events{/privacy}","received_events_url":"https://api.github.com/users/scrapy/received_events","type":"Organization","site_admin":false},"repo":{"id":529502,"name":"scrapy","full_name":"scrapy/scrapy","owner":{"login":"scrapy","id":733635,"avatar_url":"https://avatars.githubusercontent.com/u/733635?v=3","gravatar_id":"","url":"https://api.github.com/users/scrapy","html_url":"https://github.com/scrapy","followers_url":"https://api.github.com/users/scrapy/followers","following_url":"https://api.github.com/users/scrapy/following{/other_user}","gists_url":"https://api.github.com/users/scrapy/gists{/gist_id}","starred_url":"https://api.github.com/users/scrapy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scrapy/subscriptions","organizations_url":"https://api.github.com/users/scrapy/orgs","repos_url":"https://api.github.com/users/scrapy/repos","events_url":"https://api.github.com/users/scrapy/events{/privacy}","received_events_url":"https://api.github.com/users/scrapy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scrapy/scrapy","description":"Scrapy, a fast high-level web crawling & scraping framework for Python.","fork":false,"url":"https://api.github.com/repos/scrapy/scrapy","forks_url":"https://api.github.com/repos/scrapy/scrapy/forks","keys_url":"https://api.github.com/repos/scrapy/scrapy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scrapy/scrapy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scrapy/scrapy/teams","hooks_url":"https://api.github.com/repos/scrapy/scrapy/hooks","issue_events_url":"https://api.github.com/repos/scrapy/scrapy/issues/events{/number}","events_url":"https://api.github.com/repos/scrapy/scrapy/events","assignees_url":"https://api.github.com/repos/scrapy/scrapy/assignees{/user}","branches_url":"https://api.github.com/repos/scrapy/scrapy/branches{/branch}","tags_url":"https://api.github.com/repos/scrapy/scrapy/tags","blobs_url":"https://api.github.com/repos/scrapy/scrapy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scrapy/scrapy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scrapy/scrapy/git/refs{/sha}","trees_url":"https://api.github.com/repos/scrapy/scrapy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scrapy/scrapy/statuses/{sha}","languages_url":"https://api.github.com/repos/scrapy/scrapy/languages","stargazers_url":"https://api.github.com/repos/scrapy/scrapy/stargazers","contributors_url":"https://api.github.com/repos/scrapy/scrapy/contributors","subscribers_url":"https://api.github.com/repos/scrapy/scrapy/subscribers","subscription_url":"https://api.github.com/repos/scrapy/scrapy/subscription","commits_url":"https://api.github.com/repos/scrapy/scrapy/commits{/sha}","git_commits_url":"https://api.github.com/repos/scrapy/scrapy/git/commits{/sha}","comments_url":"https://api.github.com/repos/scrapy/scrapy/comments{/number}","issue_comment_url":"https://api.github.com/repos/scrapy/scrapy/issues/comments{/number}","contents_url":"https://api.github.com/repos/scrapy/scrapy/contents/{+path}","compare_url":"https://api.github.com/repos/scrapy/scrapy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scrapy/scrapy/merges","archive_url":"https://api.github.com/repos/scrapy/scrapy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scrapy/scrapy/downloads","issues_url":"https://api.github.com/repos/scrapy/scrapy/issues{/number}","pulls_url":"https://api.github.com/repos/scrapy/scrapy/pulls{/number}","milestones_url":"https://api.github.com/repos/scrapy/scrapy/milestones{/number}","notifications_url":"https://api.github.com/repos/scrapy/scrapy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scrapy/scrapy/labels{/name}","releases_url":"https://api.github.com/repos/scrapy/scrapy/releases{/id}","deployments_url":"https://api.github.com/repos/scrapy/scrapy/deployments","created_at":"2010-02-22T02:01:14Z","updated_at":"2016-10-17T08:36:09Z","pushed_at":"2016-10-13T19:23:45Z","git_url":"git://github.com/scrapy/scrapy.git","ssh_url":"git@github.com:scrapy/scrapy.git","clone_url":"https://github.com/scrapy/scrapy.git","svn_url":"https://github.com/scrapy/scrapy","homepage":"http://scrapy.org","size":33846,"stargazers_count":16451,"watchers_count":16451,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":4529,"mirror_url":null,"open_issues_count":435,"forks":4529,"open_issues":435,"watchers":16451,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scrapy/scrapy/pulls/1466"},"html":{"href":"https://github.com/scrapy/scrapy/pull/1466"},"issue":{"href":"https://api.github.com/repos/scrapy/scrapy/issues/1466"},"comments":{"href":"https://api.github.com/repos/scrapy/scrapy/issues/1466/comments"},"review_comments":{"href":"https://api.github.com/repos/scrapy/scrapy/pulls/1466/comments"},"review_comment":{"href":"https://api.github.com/repos/scrapy/scrapy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scrapy/scrapy/pulls/1466/commits"},"statuses":{"href":"https://api.github.com/repos/scrapy/scrapy/statuses/2891e02bcb85bf61738f9f3b24ab6fcf2d9c134a"}}}}
{"actor":{"display_login":"redapple"}}