response.setDate("Date", System.currentTimeMillis());
/** * This is used as a convenience method for adding a header that * needs to be parsed into a HTTP date string. This will convert * the date given into a date string defined in RFC 2616 sec 3.3.1. * This will perform a <code>remove</code> using the issued header * name before the header value is set. * * @param name the name of the HTTP message header to be added * @param date the value constructed as an RFC 1123 date string */ public void setDate(String name, long date) { response.setDate(name, date); }
/** * This is used as a convenience method for adding a header that * needs to be parsed into a HTTP date string. This will convert * the date given into a date string defined in RFC 2616 sec 3.3.1. * This will perform a <code>remove</code> using the issued header * name before the header value is set. * * @param name the name of the HTTP message header to be added * @param date the value constructed as an RFC 1123 date string */ public void setDate(String name, long date) { response.setDate(name, date); }
/** * This is used as a convenience method for adding a header that * needs to be parsed into a HTTP date string. This will convert * the date given into a date string defined in RFC 2616 sec 3.3.1. * This will perform a <code>remove</code> using the issued header * name before the header value is set. * * @param name the name of the HTTP message header to be added * @param date the value constructed as an RFC 1123 date string */ public void setDate(String name, long date) { response.setDate(name, date); }
protected void addStandardHeaders(Response response, String responseContentType) { long time = System.currentTimeMillis(); response.setValue("Content-Type", responseContentType); response.setValue("Server", "Fixd/1.0 (Simple 5.1.4)"); response.setDate("Date", time); response.setDate("Last-Modified", time); } }
/** * This is used to respond to the client with a HTTP 400 response * indicating the WebSocket handshake failed. No response body is * sent with the rejection message and the underlying TCP channel * is closed to prevent further use of the connection. */ private void reject() throws IOException { long time = System.currentTimeMillis(); response.setStatus(Status.BAD_REQUEST); response.setValue(CONNECTION, CLOSE); response.setDate(DATE, time); String header = response.toString(); byte[] message = header.getBytes("UTF-8"); trace.trace(WRITE_HEADER, header); writer.write(message); writer.flush(); writer.close(); }
/** * This is used to respond to the client with a HTTP 400 response * indicating the WebSocket handshake failed. No response body is * sent with the rejection message and the underlying TCP channel * is closed to prevent further use of the connection. */ private void reject() throws IOException { long time = System.currentTimeMillis(); response.setStatus(Status.BAD_REQUEST); response.setValue(CONNECTION, CLOSE); response.setDate(DATE, time); String header = response.toString(); byte[] message = header.getBytes("UTF-8"); trace.trace(WRITE_HEADER, header); writer.write(message); writer.flush(); writer.close(); }
@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(); } } }
/** * This is used to respond to the client with a HTTP 101 response * to indicate that the WebSocket handshake succeeeded. Once this * response has been sent all traffic between the client and * server will be with WebSocket frames as defined by RFC 6455. */ private void accept() throws IOException { long time = System.currentTimeMillis(); String accept = token.create(); response.setStatus(Status.SWITCHING_PROTOCOLS); response.setDescription(UPGRADE); response.setValue(CONNECTION, UPGRADE); response.setDate(DATE, time); response.setValue(SEC_WEBSOCKET_ACCEPT, accept); response.setValue(UPGRADE, WEBSOCKET); String header = response.toString(); byte[] message = header.getBytes("UTF-8"); trace.trace(WRITE_HEADER, header); writer.write(message); writer.flush(); } }
/** * This is used to respond to the client with a HTTP 101 response * to indicate that the WebSocket handshake succeeeded. Once this * response has been sent all traffic between the client and * server will be with WebSocket frames as defined by RFC 6455. */ private void accept() throws IOException { long time = System.currentTimeMillis(); String accept = token.create(); response.setStatus(Status.SWITCHING_PROTOCOLS); response.setDescription(UPGRADE); response.setValue(CONNECTION, UPGRADE); response.setDate(DATE, time); response.setValue(SEC_WEBSOCKET_ACCEPT, accept); response.setValue(UPGRADE, WEBSOCKET); String header = response.toString(); byte[] message = header.getBytes("UTF-8"); trace.trace(WRITE_HEADER, header); writer.write(message); writer.flush(); } }
response.setContentType("application/octet-stream"); response.setValue("Server", "SDFS Management Server"); response.setDate("Date", time); response.setDate("Last-Modified", time); response.getOutputStream().write(rslt); response.getOutputStream().flush(); } else if (request.getTarget().startsWith(METADATA_PATH)) { long time = System.currentTimeMillis(); response.setDate("Date", time); response.setDate("Last-Modified", time); String path = Main.volume.getPath() + File.separator + request.getTarget().substring(METADATA_PATH.length()); response.setContentType("application/json"); response.setValue("Server", "SDFS Management Server"); response.setDate("Date", time); response.setDate("Last-Modified", time); PrintStream body = response.getPrintStream(); body.println(GetJSONAttributes.getResult(path,uuid,num)); response.setDate("Date", time); response.setDate("Last-Modified", time); response.setContentType("application/octet-stream"); response.setValue("Server", "SDFS Management Server"); response.setDate("Date", time); response.setDate("Last-Modified", time); response.setContentLength(data.length);
@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); } } }