This should be replaced with json and the url shouldl be built in the client side.
HttpResponse::writeText
HttpResponse::write