code: def _guess_content_type(url):
      '''
      Guess content type by url.
  
      >>> _guess_content_type('http://test/A.HTML')
      'text/html'
      >>> _guess_content_type('http://test/a.jpg')
      'image/jpeg'
      >>> _guess_content_type('/path.txt/aaa')
      'application/octet-stream'
      '''
      OCTET_STREAM = 'application/octet-stream'
      n = url.rfind('.')
      if n == -1:
          return OCTET_STREAM
      return mimetypes.types_map.get(url[n:].lower(), OCTET_STREAMf _guess_content_type(url):
      '''
      Guess content type by url.
  
      >>> _guess_content_type('http://test/A.HTML')
      'text/html'
      >>> _guess_content_type('http://test/a.jpg')
      'image/jpeg'
      >>> _guess_content_type('/path.txt/aaa')
      'application/octet-stream'
      '''
      OCTET_STREAM = 'application/octet-stream'
      n = url.rfind('.')
      if n == -1:
          return OCTET_STREAM
      return mimetypes.types_map.get(url[n:].lower(), OCTET_STREAM)
docs: Guess content type by url.
  
      >>> _guess_content_type('http://test/A.HTML')
      'text/html'
      >>> _guess_content_type('http://test/a.jpg')
      'image/jpeg'
      >>> _guess_content_type('/path.txt/aaa')
      'application/octet-stream'