@Test public void shouldAddDefaultHeadersForRootContext() throws Exception { jetty9Server.configure(); jetty9Server.startHandlers(); HttpServletResponse response = mock(HttpServletResponse.class); when(response.getWriter()).thenReturn(mock(PrintWriter.class)); HttpServletRequest request = mock(HttpServletRequest.class); Request baseRequest = mock(Request.class); when(baseRequest.getDispatcherType()).thenReturn(DispatcherType.REQUEST); when(baseRequest.getHttpFields()).thenReturn(mock(HttpFields.class)); ContextHandler rootPathHandler = getLoadedHandlers().get(GoServerLoadingIndicationHandler.class); rootPathHandler.setServer(server); rootPathHandler.start(); rootPathHandler.handle("/something", baseRequest, request, response); verify(response).setHeader("X-XSS-Protection", "1; mode=block"); verify(response).setHeader("X-Content-Type-Options", "nosniff"); verify(response).setHeader("X-Frame-Options", "SAMEORIGIN"); verify(response).setHeader("X-UA-Compatible", "chrome=1"); }
public void handle(Runnable runnable) { handle(null,runnable); }
public void handle(Runnable runnable) { handle(null,runnable); }
/** * Run a runnable in the context (with context classloader set) if * there is one, otherwise just run it. * @param r the runnable */ public void run (Runnable r) { if (_context != null) _context.getContextHandler().handle(r); else r.run(); }
void runInContext(AsyncContextEvent event,Runnable runnable) { ContextHandler contextHandler = getContextHandler(event); if (contextHandler==null) runnable.run(); else contextHandler.handle(_channel.getRequest(),runnable); }
void runInContext(AsyncContextEvent event,Runnable runnable) { ContextHandler contextHandler = getContextHandler(event); if (contextHandler==null) runnable.run(); else contextHandler.handle(_channel.getRequest(),runnable); }
@Override public void run() { ((Context)event.getServletContext()).getContextHandler().handle(run); } });
public void run() { ((Context)event.getServletContext()).getContextHandler().handle(run); } });
public void run() { ((Context)event.getServletContext()).getContextHandler().handle(run); } });
public void run() { ((Context)event.getServletContext()).getContextHandler().handle(run); } });
@Override public void run() { ((Context)event.getServletContext()).getContextHandler().handle(run); } });
public void run() { ((Context)event.getServletContext()).getContextHandler().handle(run); } });
public void run() { ((Context)event.getServletContext()).getContextHandler().handle(run); } });
private void handleWithContext() { ContextHandler context = getState().getContextHandler(); if (context != null) context.handle(getRequest(), this); else handle(); }
@Override public void run() { state().getAsyncContextEvent().getContext().getContextHandler().handle(task); } });
public void complete() { // just like resume, except don't set _dispatched=true; boolean handle=false; synchronized (this) { if (_async!=Async.STARTED && _async!=Async.EXPIRING) throw new IllegalStateException(this.getStatusString()); _async=Async.COMPLETE; if (_state==State.ASYNC_WAIT) { handle=true; _state=State.ASYNC_WOKEN; } } cancelTimeout(); if (handle) { ContextHandler handler=getContextHandler(); if (handler!=null) handler.handle(_channel); else _channel.handle(); } }
@Override public void run() { state().getAsyncContextEvent().getContext().getContextHandler().handle(channel.getRequest(),task); } });
@Override public void run() { state().getAsyncContextEvent().getContext().getContextHandler().handle(channel.getRequest(),task); } });
NullArgumentException.validateNotNull(context, "Context (handler) for " + target); context.handle(target, baseRequest, request, response);