docs: def displayResponse(request, openid_response):
      """
      Display an OpenID response.  Errors will be displayed directly to
      the user; successful responses and other protocol-level messages
      will be sent using the proper mechanism (i.e., direct response,
      redirection, etc.).
      """
      s = getServer(request)
  
      # Encode the response into something that is renderable.
      try:
          webresponse = s.encodeResponse(openid_response)
      except EncodingError, why:
          # If it couldn't be encoded, display an error.
          text = why.response.encodeToKVForm()
          return direct_to_template(
              request,
              'server/endpoint.html',
              {'error': cgi.escape(text)})
  
      # Construct the appropriate django framework response.
      r = http.HttpResponse(webresponse.body)
      r.status_code = webresponse.code
  
      for header, value in webresponse.headers.iteritems():
          r[header] = value
  
      return r