def process_redirect(self, response): status, link, encoding = BaseService.process_redirect(self, response) if link.startswith('/') and link.endswith('/'): url = self.params['url_template'].format(shortcode=self.current_shortcode) + '/' response = self.fetch_url(url, 'head') status, link, encoding = BaseService.process_redirect(self, response) if link in ('https://myspace.com/404', 'http://myspace.com/404'): return URLStatus.not_found, None, None else: return status, link, encoding
def process_redirect(self, response): if response.status_code == 302: if 'location' not in response.headers: raise UnexpectedNoResult() url = urlparse.urlparse(response.headers['location']) if url.scheme != "http" or url.netloc != "bit.ly" or url.path != "/a/warning": raise UnexpectedNoResult("Unexpected Location header after HTTP status 302") if sys.version_info[0] == 2: query = urlparse.parse_qs(url.query.encode('latin-1')) else: query = urlparse.parse_qs(url.query) if not ("url" in query and len(query["url"]) == 1) or not ("hash" in query and len(query["hash"]) == 1): raise UnexpectedNoResult("Unexpected Location header after HTTP status 302") if query["hash"][0] != self.current_shortcode: raise UnexpectedNoResult("Hash mismatch for HTTP status 302") if sys.version_info[0] == 2: unshortened_url = query["url"][0].decode('latin-1') else: unshortened_url = query["url"][0] return (URLStatus.ok, unshortened_url, None) else: return BaseService.process_redirect(self, response)
def process_redirect(self, response): status, url, encoding = BaseService.process_redirect(self, response) if url == 'http://yatuc.com': return URLStatus.not_found, None, None else: return status, url, encoding
def process_redirect(self, response): status, url, encoding = BaseService.process_redirect(self, response) if status == URLStatus.ok: if url == 'http://www.godaddy.com/default.aspx?isc=xcowebgd': return URLStatus.not_found, None, None return status, url, encoding
def process_redirect(self, response): status, url, encoding = BaseService.process_redirect(self, response) if url.startswith('http://totally.awe.sm/') and \ url.endswith(self.current_shortcode): return URLStatus.not_found, None, None else: return status, url, encoding
def process_redirect(self, response): try: url_status, link, encoding = BaseService.process_redirect(self, response) except UnexpectedNoResult: if "Location" not in response.headers: return URLStatus.not_found, None, None else: raise if link == "/site/getprivate?snip=" + self.current_shortcode: return URLStatus.unavailable, None, None else: return url_status, link, encoding
def process_redirect(self, response): try: url_status, link, encoding = BaseService.process_redirect( self, response) except UnexpectedNoResult: if 'Location' not in response.headers: return URLStatus.not_found, None, None else: raise if link == "/site/getprivate?snip=" + self.current_shortcode: return URLStatus.unavailable, None, None else: return url_status, link, encoding
def process_redirect(self, response): if response.status_code == 200: return self._fetch_200(response) else: if 'Location' in response.headers and response.status_code == 301: tiny = response.headers.get("X-tiny") if tiny and tiny[:3] == "aff": return self._preview(self.current_shortcode, response.headers['Location']) try: return BaseService.process_redirect(self, response) except UnexpectedNoResult: return (URLStatus.unavailable, None, None)
def process_redirect(self, response): if response.status_code == 200: return self._fetch_200(response) else: if 'Location' in response.headers and response.status_code == 301: tiny = response.headers.get("X-tiny") if tiny and tiny[:3] == "aff": return self._preview( self.current_shortcode, response.headers['Location'] ) try: return BaseService.process_redirect(self, response) except UnexpectedNoResult: return (URLStatus.unavailable, None, None)
def process_redirect(self, response): try: return BaseService.process_redirect(self, response) except UnexpectedNoResult: return (URLStatus.not_found, None, None)