/** * This is used to set the content type for the response. Typically * a response will contain a message body of some sort. This is used * to conveniently set the type for that response. Setting the * content type can also be done explicitly if desired. * * @param type this is the type that is to be set in the response */ public void setContentType(String type) { response.setContentType(type); }
/** * This is used to set the content type for the response. Typically * a response will contain a message body of some sort. This is used * to conveniently set the type for that response. Setting the * content type can also be done explicitly if desired. * * @param type this is the type that is to be set in the response */ public void setContentType(String type) { response.setContentType(type); }
/** * This is used to set the content type for the response. Typically * a response will contain a message body of some sort. This is used * to conveniently set the type for that response. Setting the * content type can also be done explicitly if desired. * * @param type this is the type that is to be set in the response */ public void setContentType(String type) { response.setContentType(type); }
private void downloadFile(File f, Request request, Response response) throws IOException { if (f.exists()) { response.setContentType("application/octet-stream"); response.addValue("Server", "SDFS Management Server"); response.setContentLength(f.length()); InputStream in = new FileInputStream(f); OutputStream out = response.getOutputStream(); byte[] buf = new byte[32768]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } out.flush(); in.close(); out.close(); } else { response.setCode(404); PrintStream body = response.getPrintStream(); body.println("could not find " + f.getPath()); body.close(); SDFSLogger.getLog().warn("unable to find " + f.getPath()); } }
rsp.setContentType("text/xml"); byte[] rb = rsString.getBytes(); rsp.setContentLength(rb.length);
rsp.setContentType("application/octet-stream"); rsp.addValue("Server", "SDFS Management Server"); rsp.setDate("Date", time); rsp.setContentType("text/xml"); byte[] rb = rsString.getBytes(); rsp.setContentLength(rb.length);
rsp.setContentType("text/xml"); byte[] rb = rsString.getBytes(); rsp.setContentLength(rb.length);
@Override public void handle(Request request, Response response) { try { PrintStream body = response.getPrintStream(); long time = System.currentTimeMillis(); response.setStatus(status); response.setContentType("text/plain"); response.setDate("Date", time); response.setDate("Last-Modified", time); log.info("mock container returning: status [{}], content [{}]", status, responseContent); body.println(responseContent); body.close(); } catch (Exception e) { e.printStackTrace(); } } }
response.setContentType("text/xml"); byte[] rb = rsString.getBytes(); response.setContentLength(rb.length); byte[] rslt = new BatchGetBlocksCmd().getResult(rb); long time = System.currentTimeMillis(); response.setContentType("application/octet-stream"); response.setValue("Server", "SDFS Management Server"); response.setDate("Date", time); response.setContentType("text/xml"); byte[] rb = rsString.getBytes(); response.setContentLength(rb.length); } else { long time = System.currentTimeMillis(); response.setContentType("application/json"); response.setValue("Server", "SDFS Management Server"); response.setDate("Date", time); byte[] data = HCServiceProxy.fetchHashChunk(hash).getData(); long time = System.currentTimeMillis(); response.setContentType("application/octet-stream"); response.setValue("Server", "SDFS Management Server"); response.setDate("Date", time); byte[] rslt = new BatchGetBlocksCmd().getResult(rb); long time = System.currentTimeMillis(); response.setContentType("application/octet-stream");
@Override public void handle(Request request, Response response) { try { PrintStream body = response.getPrintStream(); long time = System.currentTimeMillis(); response.setValue("Content-Type", "text/plain"); response.setContentType("application/xml;charset=utf-8"); response.setDate("Date", time); response.setDate("Last-Modified", time); String path = request.getAddress().getPath().getPath(); log.trace("request path is {}", path); StatusAndContent statusAndContent = tryMatchPath(path); Status status = statusAndContent.status; response.setStatus(status); String content = statusAndContent.content; log.trace("mock container returning: status [{}], content [{}]", status, content); body.println(content); body.close(); } catch (Exception e) { e.printStackTrace(); response.setStatus(Status.INTERNAL_SERVER_ERROR); try { response.close(); } catch (IOException e1) { throw new RuntimeException(e1); } } }