docs: def _handle_request(self, request):
          """Process the headers and get the file"""
  
          # Check if this is a persistent connection.
          if request['version'] == 'HTTP/1.1':
              self.keepalive = not request.get('Connection') == 'close'
          elif request['version'] == 'HTTP/1.0':
              self.keepalive = request.get('Connection') == 'Keep-Alive'
  
          # Check if we're getting a sane request
          if request['method'] not in ('GET'):
              raise InvalidRequestError(501, 'Method not implemented')
          if request['version'] not in ('HTTP/1.0', 'HTTP/1.1'):
              raise InvalidRequestError(
                  505, 'Version not supported. Supported versions are: {}, {}'
                  .format('HTTP/1.0', 'HTTP/1.1'))
  
          host, location = self._get_request_uri(request)
  
          # We must ignore the Host header if a host is specified in GET
          if host is None:
              host = request.get('Host')
  
          # Check if this request is intended for this webserver
          if host is not None and not host == self.host:
              self.logger.info('Got a request for unknown host %s', host)
              raise InvalidRequestError(404, "We don't serve this host")
  
          filename = os.path.join(self.folder, unquote(location))
          self.logger.debug('trying to serve %s', filename)
  
          if os.path.isdir(filename):
              filename = os.path.join(filename, 'index.html')
  
          if not os.path.isfile(filename):
              raise InvalidRequestError(404, 'Not Found')
  
          # Start response with version
          response = _get_response(version=request['version'])
  
          # timeout negotiation
          match = re.match(r'timeout=(\d+)', request.get('Keep-Alive', ''))
          if match is not None:
              requested_timeout = int(match.group(1))
              if requested_timeout < self._timeout:
                  self._timeout = requested_timeout
  
          # tell the client our timeout
          if self.keepalive:
              response['headers'][
                  'Keep-Alive'] = 'timeout={}'.format(self._timeout)
  
          # Set Content-Type
          response['headers']['Content-Type'] = mimetypes.guess_type(
              filename)[0] or 'text/plain'
  
          # Generate E-tag
          sha1 = hashlib.sha1()
          with open(filename, 'rb') as fp:
              response['body'] = fp.read()
              sha1.update(response['body'])
          etag = sha1.hexdigest()
  
          # Create 304 response if if-none-match matches etag
          if request.get('If-None-Match') == '"{}"'.format(etag):
              # 304 responses shouldn't contain many headers we might already
              # have added.
              response = _get_response(code=304)
  
          response['headers']['Etag'] = '"{}"'.format(etag)
  
          self._write_response(response)