code: def download(url, proxies=None):
      
      # Handle default argument
      if proxies is None:
          proxies = [""]
  
      # Loop over all available connections
      for proxy in proxies:
          # Handle no proxy case
          if proxy == "":
              socket.socket = DEFAULT_SOCKET
          # Handle SOCKS proxy
          elif proxy.startswith('socks'):
              if proxy[5] == '4':
                  proxy_type = socks.SOCKS4
              else:
                  proxy_type = socks.SOCKS5
              proxy = proxy[proxy.find('://') + 3:]
              try:
                  proxy, port = proxy.split(':')
              except ValueError:
                  port = None
              socks.set_default_proxy(proxy_type, proxy, port)
              socket.socket = socks.socksocket
          # Handle generic HTTP proxy
          else:
              try:
                  proxy, port = proxy.split(':')
              except ValueError:
                  port = None
              socks.set_default_proxy(socks.HTTP, proxy, port)
              socket.socket = socks.socksocket
  
          downloaded = _download_helper(url)
          if downloaded is not None:
              return downloaded
  
      # In case of running out of proxies, return (None, None)
      return (None, None)
docs: Download a PDF or DJVU document from a url, eventually using proxies.
  
      :params url: The URL to the PDF/DJVU document to fetch.
      :params proxies: An optional list of proxies to use. Proxies will be \
              used sequentially. Proxies should be a list of proxy strings. \
              Do not forget to include ``""`` (empty string) in the list if \
              you want to try direct fetching without any proxy.
  
      :returns: A tuple of the raw content of the downloaded data and its \
              associated content-type. Returns ``(None, None)`` if it was \
              unable to download the document.
  
      >>> download("http://arxiv.org/pdf/1312.4006.pdf") # doctest: +SKIP