Commit faedaf04 authored by nextime's avatar nextime

Add option to block location redirect

parent bd3a5c82
......@@ -145,7 +145,7 @@ class HTTPPageGetter(client.HTTPPageGetter):
def handleStatus_301(self):
l = self.headers.get('location')
if not l:
if not l or self.factory.nolocation:
self.handleStatusDefault()
return
url = l[0]
......@@ -315,7 +315,7 @@ class HTTPClientFactoryProgressStream(HTTPClientFactoryProgress):
def getPage(url, progress=False, stream=False, proxy_host = None, proxy_port = None, headers=None,
contextFactory = None, uniqueid = False, http_user=None, http_password=None, headerscb=None, *args, **kwargs):
contextFactory = None, uniqueid = False, http_user=None, http_password=None, headerscb=None, nolocation=False, *args, **kwargs):
parsed = urlparse.urlsplit(url)
if not http_user:
......@@ -345,6 +345,7 @@ def getPage(url, progress=False, stream=False, proxy_host = None, proxy_port = N
factory.http_user = http_user
factory.http_password = http_password
factory.uniqueid=uniqueid
factory.nolocation=nolocation
if scheme == 'https':
from twisted.internet import ssl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment