Esempio n. 1
0
 def parse_url(self):
     self.scheme = self.host = _('Unknown')
     if self.url is None:
         self.invalid_url = True
         return 
     try:
         self.url = self.url.encode("ascii")
     except UnicodeError:
         self.invalid_url = True
         return
     scheme, host, port, path = download_utils.parse_url(self.url)
     self.scheme = scheme
     self.host = host
     self.path = path
     if scheme not in ['http', 'https'] or host == '' or path == '':
         self.invalid_url = True
         return
Esempio n. 2
0
def _has_video_extension(enclosure, key):
    from miro import download_utils
    if key in enclosure:
        elems = download_utils.parse_url(enclosure[key], split_path=True)
        return is_allowed_filename(elems[3])
    return False
Esempio n. 3
0
 def check(self, url, scheme, host, port, path):
     result = parse_url(url)
     self.assertEquals(result[0], scheme)
     self.assertEquals(result[1], host)
     self.assertEquals(result[2], port)
     self.assertEquals(result[3], path)
Esempio n. 4
0
         logging.warn("Error parsing status line (%r): %s", line, e)
         self.status_code = 200
     else:
         if 300 <= code <= 399 and code != 301:
             self.saw_temporary_redirect = True
     return
 if line == '':
     if self.status_code == 100:
         # server sent a HTTP 100 continue.  we ditch the data
         # we got so far and ignore this "empty header" because
         # it's not the response we're looking for.
         self.status_code = None
     elif 'location' in self.headers:
         # doing a redirect, clear out the headers
         redirect_url = self.headers['location']
         scheme, _, _, _ = download_utils.parse_url(redirect_url)
         if not scheme:
             logging.warn("%s: Non-absolute redirect URL: %s",
                          self.options.url, redirect_url)
         elif scheme not in ('http', 'https'):
             self.cancel(remove_file=True)
             self.call_errback(InvalidRedirect(redirect_url))
             return
         self.headers = {}
     elif not self.headers_finished:
         curl_manager.call_after_perform(self.on_headers_finished)
         self.headers_finished = True
     else:
         msg = "httpclient: saw multiple empty header lines (%s)"
         logging.warning(msg, self.options.url)
     return