# File lib/openid/server.rb, line 719
      def encode(response)
        webresponse = WebResponse.new

        case response.which_encoding?
        when ENCODE_KVFORM
          webresponse.code = HTTP_ERROR if response.kind_of?(Exception)
          webresponse.body = response.encode_to_kvform

        when ENCODE_URL
          webresponse.set_redirect(response.encode_to_url)

        else
          # don't know how to encode response
          raise EncodingError.new(response)
        end
        
        return webresponse
      end