@Test public void handleIllegalMethod() throws Exception { ServerRequest request = mockRequestWithPath("/"); ServerResponse response = mock(ServerResponse.class); TestContentHandler handler = new TestContentHandler("/root", true); handler.handle(Http.Method.POST, request, response); verify(request).next(); assertThat(handler.counter.get(), is(0)); }
void handle(Http.RequestMethod method, ServerRequest request, ServerResponse response) { if ((method != Http.Method.GET) && (method != Http.Method.HEAD)) { request.next(); return; } String requestPath = request.path().toString(); if (requestPath.startsWith("/")) { requestPath = requestPath.substring(1); } try { if (!doHandle(method, requestPath, request, response)) { request.next(); } } catch (HttpException httpException) { if (httpException.status().code() == Http.Status.NOT_FOUND_404.code()) { request.next(); } else { throw httpException; } } catch (Exception e) { LOGGER.log(Level.FINE, "Failed to access static resource", e); throw new HttpException("Cannot access static resource!", Http.Status.INTERNAL_SERVER_ERROR_500, e); } }
StaticContentHandler { void handle(Http.RequestMethod method, ServerRequest request, ServerResponse response) { if ((method != Http.Method.GET) && (method != Http.Method.HEAD)) { request.next(); return; } String requestPath = request.path().toString(); if (requestPath.startsWith("/")) { requestPath = requestPath.substring(1); } try { if (!doHandle(method, requestPath, request, response)) { request.next(); } } catch (HttpException httpException) { if (httpException.status().code() == Http.Status.NOT_FOUND_404.code()) { request.next(); } else { throw httpException; } } catch (Exception e) { LOGGER.log(Level.FINE, "Failed to access static resource", e); throw new HttpException("Cannot access static resource!", Http.Status.INTERNAL_SERVER_ERROR_500, e); } } }
StaticContentHandler { void handle(Http.RequestMethod method, ServerRequest request, ServerResponse response) { if ((method != Http.Method.GET) && (method != Http.Method.HEAD)) { request.next(); return; } String requestPath = request.path().toString(); if (requestPath.startsWith("/")) { requestPath = requestPath.substring(1); } try { if (!doHandle(method, requestPath, request, response)) { request.next(); } } catch (HttpException httpException) { if (httpException.status().code() == Http.Status.NOT_FOUND_404.code()) { request.next(); } else { throw httpException; } } catch (Exception e) { LOGGER.log(Level.FINE, "Failed to access static resource", e); throw new HttpException("Cannot access static resource!", Http.Status.INTERNAL_SERVER_ERROR_500, e); } } StaticContentHandler(String welcomeFilename, ContentTypeSelector contentTypeSelector); }
StaticContentHandler { void handle(Http.RequestMethod method, ServerRequest request, ServerResponse response) { if ((method != Http.Method.GET) && (method != Http.Method.HEAD)) { request.next(); return; } String requestPath = request.path().toString(); if (requestPath.startsWith("/")) { requestPath = requestPath.substring(1); } try { if (!doHandle(method, requestPath, request, response)) { request.next(); } } catch (HttpException httpException) { if (httpException.status().code() == Http.Status.NOT_FOUND_404.code()) { request.next(); } else { throw httpException; } } catch (Exception e) { LOGGER.log(Level.FINE, "Failed to access static resource", e); throw new HttpException("Cannot access static resource!", Http.Status.INTERNAL_SERVER_ERROR_500, e); } } StaticContentHandler(String welcomeFilename, ContentTypeSelector contentTypeSelector);  }
StaticContentHandler { void handle(Http.RequestMethod method, ServerRequest request, ServerResponse response) { if ((method != Http.Method.GET) && (method != Http.Method.HEAD)) { request.next(); return; } String requestPath = request.path().toString(); if (requestPath.startsWith("/")) { requestPath = requestPath.substring(1); } try { if (!doHandle(method, requestPath, request, response)) { request.next(); } } catch (HttpException httpException) { if (httpException.status().code() == Http.Status.NOT_FOUND_404.code()) { request.next(); } else { throw httpException; } } catch (Exception e) { LOGGER.log(Level.FINE, "Failed to access static resource", e); throw new HttpException("Cannot access static resource!", Http.Status.INTERNAL_SERVER_ERROR_500, e); } } StaticContentHandler(String welcomeFilename, ContentTypeSelector contentTypeSelector);   }