@Test public void testNotOverride() throws Exception { HttpServerExchange exchange = new MockUp<HttpServerExchange>() { @Mock public HeaderMap getRequestHeaders() { throw new AssertionError(); } @Mock public <T> T getAttachment(final AttachmentKey<T> key) { throw new AssertionError(); } }.getMockInstance(); exchange.setRequestMethod(Methods.GET); this.target.handleRequest(exchange); }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { if (Methods.POST.equals(exchange.getRequestMethod())) { String newMethod = exchange.getRequestHeaders().getFirst(HEADER); Optional<HttpString> opt = HttpMethod.find(newMethod); if (opt.isPresent()) { exchange.setRequestMethod(opt.get()); } else { FormData data = exchange .getAttachment(FormDataParser.FORM_DATA); if (data != null) { FormData.FormValue fv = data.getFirst(FORM); if (fv != null && fv.isFile() == false) { HttpMethod.find(fv.getValue()).map( exchange::setRequestMethod); } } } } this.next.handleRequest(exchange); }
MethodOverrideHandler implements HttpHandler { @Override public void handleRequest(HttpServerExchange exchange) throws Exception { if (Methods.POST.equals(exchange.getRequestMethod())) { String newMethod = exchange.getRequestHeaders().getFirst(HEADER); Optional<HttpString> opt = HttpMethod.find(newMethod); if (opt.isPresent()) { exchange.setRequestMethod(opt.get()); } else { FormData data = exchange .getAttachment(FormDataParser.FORM_DATA); if (data != null) { FormData.FormValue fv = data.getFirst(FORM); if (fv != null && fv.isFile() == false) { HttpMethod.find(fv.getValue()).map( exchange::setRequestMethod); } } } } this.next.handleRequest(exchange); } }
MethodOverrideHandler implements HttpHandler { @Override public void handleRequest(HttpServerExchange exchange) throws Exception { if (Methods.POST.equals(exchange.getRequestMethod())) { String newMethod = exchange.getRequestHeaders().getFirst(HEADER); Optional<HttpString> opt = HttpMethod.find(newMethod); if (opt.isPresent()) { exchange.setRequestMethod(opt.get()); } else { FormData data = exchange .getAttachment(FormDataParser.FORM_DATA); if (data != null) { FormData.FormValue fv = data.getFirst(FORM); if (fv != null && fv.isFile() == false) { HttpMethod.find(fv.getValue()).map( exchange::setRequestMethod); } } } } this.next.handleRequest(exchange); } MethodOverrideHandler(HttpHandler next); }
MethodOverrideHandler implements HttpHandler { @Override public void handleRequest(HttpServerExchange exchange) throws Exception { if (Methods.POST.equals(exchange.getRequestMethod())) { String newMethod = exchange.getRequestHeaders().getFirst(HEADER); Optional<HttpString> opt = HttpMethod.find(newMethod); if (opt.isPresent()) { exchange.setRequestMethod(opt.get()); } else { FormData data = exchange .getAttachment(FormDataParser.FORM_DATA); if (data != null) { FormData.FormValue fv = data.getFirst(FORM); if (fv != null && fv.isFile() == false) { HttpMethod.find(fv.getValue()).map( exchange::setRequestMethod); } } } } this.next.handleRequest(exchange); } MethodOverrideHandler(HttpHandler next); @Override void handleRequest(HttpServerExchange exchange); }
MethodOverrideHandler implements HttpHandler { @Override public void handleRequest(HttpServerExchange exchange) throws Exception { if (Methods.POST.equals(exchange.getRequestMethod())) { String newMethod = exchange.getRequestHeaders().getFirst(HEADER); Optional<HttpString> opt = HttpMethod.find(newMethod); if (opt.isPresent()) { exchange.setRequestMethod(opt.get()); } else { FormData data = exchange .getAttachment(FormDataParser.FORM_DATA); if (data != null) { FormData.FormValue fv = data.getFirst(FORM); if (fv != null && fv.isFile() == false) { HttpMethod.find(fv.getValue()).map( exchange::setRequestMethod); } } } } this.next.handleRequest(exchange); } MethodOverrideHandler(HttpHandler next); @Override void handleRequest(HttpServerExchange exchange);  }