ClientResponse resp = client.get(url);
switch (resp.getType()) {
case SUCCESS:
try {
Document doc = resp.getDocument();
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
if (doc.getEntityTag() != null)
response.setHeader("ETag", doc.getEntityTag().toString());
if (doc.getLanguage() != null)
response.setHeader("Content-Language", doc.getLanguage());
if (doc.getLastModified() != null)
response.setDateHeader("Last-Modified", doc.getLastModified().getTime());
OutputStream out = response.getOutputStream();
doc.writeTo("json", out);
} catch (Exception e) {
response.sendError(500);
return;
}
case CLIENT_ERROR: