def encode(response)
encode_as = response.which_encoding()
if encode_as == ENCODE_KVFORM
wr = @@responseFactory.new(HTTP_OK, nil,
response.encode_to_kvform())
if response.is_a?(Exception)
wr.code = HTTP_ERROR
end
elsif encode_as == ENCODE_URL
location = response.encode_to_url()
wr = @@responseFactory.new(HTTP_REDIRECT,
{'location' => location})
elsif encode_as == ENCODE_HTML_FORM
wr = @@responseFactory.new(HTTP_OK, nil,
response.to_form_markup())
else
raise EncodingError.new(response)
end
return wr
end