public void handle(Request req, Response resp) { try { if (req.getPath().getPath().contains("/redirect/")) { resp.setCode(303); resp.add("Location", "/"); } else { if (req.getPath().getPath().contains("/timeout/")) { try { Thread.sleep(500); if (req.getPath().getPath().contains("/gzip/")) { if (!"gzip".equals(req.getValue("Accept-Encoding"))) { throw new IllegalStateException("Should accept gzip");
@Override public String uri() { return request.getPath().getPath(); }
public String getPath() { return request.getPath().getPath(); }
public String getPath() { return request.getPath().getPath(); }
String contentType = "text/plain"; Path path=request.getPath(); if(path.getPath().substring(path.getPath().length()-3).equals(".js")) contentType = "application/javascript"; if(path.getPath().substring(path.getPath().length()-3).equals("css")) contentType = "text/css"; response.setDate("Date", time); response.setDate("Last-Modified", time); String filename= config.getString("pagelyzer.run.default.comparison.path").replace("/ext", "/js") +path.getPath();
String version = request.getValue(SEC_WEBSOCKET_VERSION); Path path = request.getPath(); String normal = path.getPath();
String version = request.getValue(SEC_WEBSOCKET_VERSION); Path path = request.getPath(); String normal = path.getPath();
qry = splitQuery(null); boolean cmdReq = reqPath.getPath().trim().equalsIgnoreCase("/"); body.println("authentication required"); } else if (reqPath.getPath().contains("..") || URLDecoder.decode(reqPath.getPath(), "UTF-8").contains("..")) { response.setCode(404); PrintStream body = response.getPrintStream(); body.println("invalid path " + reqPath.getPath()); SDFSLogger.getLog().error("invalid path " + reqPath.getPath()); body.close(); } else if (request.getTarget().startsWith(IO_PATH)) { } else { File f = new File(archivePath + File.separator + reqPath.getPath()); try { if (f.exists()) {
public static FullHttpRequest convert(final Request request) { byte[] data = null; try { final InputStream inputStream = request.getInputStream(); try { data = IOUtils.toByteArray(inputStream); } finally { inputStream.close(); } } catch (final IOException e) { LOGGER.error("IOException when getting request content.", e); } final FullHttpRequestImpl httpRequest = new FullHttpRequestImpl(); httpRequest.domain(request.getAddress().getDomain()); httpRequest.port(request.getAddress().getPort()); httpRequest.method(Method.valueOf(request.getMethod())); httpRequest.path(request.getPath().getPath()); if (data.length > 0) { httpRequest.content(data); } for (final String headerField : request.getNames()) { for (final String headerFieldValue : request.getValues(headerField)) { httpRequest.httpMessageHeader(headerField, headerFieldValue); } } for (final Entry<String, String> entry : request.getQuery().entrySet()) { httpRequest.queryParameter(entry.getKey(), entry.getValue()); } return httpRequest; }
@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); } } }