Refine search
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException final boolean isSmile = SmileMediaTypes.APPLICATION_JACKSON_SMILE.equals(request.getContentType()) || APPLICATION_SMILE.equals(request.getContentType()); final ObjectMapper objectMapper = isSmile ? smileMapper : jsonMapper; request.setAttribute(OBJECTMAPPER_ATTRIBUTE, objectMapper); final String requestURI = request.getRequestURI(); byte[] requestBytes = objectMapper.writeValueAsBytes(requestMap); request.setAttribute(AVATICA_QUERY_ATTRIBUTE, requestBytes); } else if (isQueryEndpoint && HttpMethod.DELETE.is(method)) { } else if (isQueryEndpoint && HttpMethod.POST.is(method)) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); response.setContentType(MediaType.APPLICATION_JSON); objectMapper.writeValue( response.getOutputStream(), ImmutableMap.of("error", errorMessage) );
@Override public void doScope( String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (target.equals("/") && request.getMethod().equals(HttpMethod.POST.asString())) { super.doScope(target, baseRequest, request, response); } } };
@Override public String getMethod() { return (this.simulateGetMethod ? HttpMethod.GET.toString() : super.getMethod()); }
static HandlerWrapper createGzipHandlerWrapper(Compression compression) { GzipHandler handler = new GzipHandler(); handler.setMinGzipSize((int) compression.getMinResponseSize().toBytes()); handler.setIncludedMimeTypes(compression.getMimeTypes()); for (HttpMethod httpMethod : HttpMethod.values()) { handler.addIncludedMethods(httpMethod.name()); } if (compression.getExcludedUserAgents() != null) { handler.setExcludedAgentPatterns(compression.getExcludedUserAgents()); } return handler; }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException { String method = request.getMethod(); if ( !method.equals(HttpMethod.GET.asString()) && !method.equals(HttpMethod.POST.asString()) && !method.equals(HttpMethod.HEAD.asString()) ) return ; response.setContentType(MimeTypes.Type.TEXT_PLAIN_UTF_8.asString()) ; response.setHeader(HttpNames.hCacheControl, "must-revalidate,no-cache,no-store"); response.setHeader(HttpNames.hPragma, "no-cache"); int code = response.getStatus() ; String message=(response instanceof Response)?((Response)response).getReason(): HttpSC.getMessage(code) ; response.getOutputStream().print(format("Error %d: %s\n", code, message)) ; } }
Request base_request = Request.getBaseRequest(request); Response base_response = base_request.getResponse(); String uri = request.getRequestURI(); if (uri==null) uri=URIUtil.SLASH; return new DeferredAuthentication(this); if (isLoginOrErrorPage(URIUtil.addPaths(request.getServletPath(),request.getPathInfo())) &&!DeferredAuthentication.isDeferred(response)) return new DeferredAuthentication(this); LOG.debug("jsecuritycheck {} {}",username,user); HttpSession session = request.getSession(false); if (user!=null) LOG.debug("authenticated {}->{}",form_auth,nuri); if (LOG.isDebugEnabled()) LOG.debug("Form authentication FAILED for " + StringUtil.printable(username)); if (_formErrorPage == null) session.setAttribute(__J_METHOD, request.getMethod()); if (MimeTypes.Type.FORM_ENCODED.is(req.getContentType()) && HttpMethod.POST.is(request.getMethod()))
throws IOException if (baseRequest.isHandled()) { return; baseRequest.setHandled(true); String method = request.getMethod(); boolean skipContent = false; if (!HttpMethod.GET.is(method)) { if (HttpMethod.HEAD.is(method)) { skipContent = true; response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); return; response.setContentType(contentType); ByteStreams.copy(resourceStream, response.getOutputStream());
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException { String method = request.getMethod(); if (!HttpMethod.GET.is(method) && !HttpMethod.POST.is(method) && !HttpMethod.HEAD.is(method)) { baseRequest.setHandled(true); return; } baseRequest.setHandled(true); response.setContentType(MimeTypes.Type.TEXT_HTML_UTF_8.asString()); response.setHeader(HttpHeader.CACHE_CONTROL.asString(), "must-revalidate,no-cache,no-store"); ByteArrayOutputStream out = new ByteArrayOutputStream(4096); OutputStreamWriter writer = new OutputStreamWriter(out, Charsets.UTF_8); String reason=(response instanceof Response)?((Response)response).getReason():null; handleErrorPage(request, writer, response.getStatus(), reason); writer.flush(); response.setContentLength(out.size()); response.getOutputStream().write(out.toByteArray(), 0, out.size()); writer.close(); } }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException String method = request.getMethod(); if (!HttpMethod.GET.is(method) && !HttpMethod.POST.is(method) && !HttpMethod.HEAD.is(method)) baseRequest.setHandled(true); return; if (error_page!=null && request.getServletContext()!=null) String old_error_page=(String)request.getAttribute(ERROR_PAGE); if (old_error_page==null || !old_error_page.equals(error_page)) return; LOG.warn("No error page "+error_page); LOG.warn(Log.EXCEPTION, e); return; if (LOG.isDebugEnabled()) LOG.debug("No Error Page mapping for request({} {}) (using default)",request.getMethod(),request.getRequestURI()); baseRequest.setHandled(true); HttpField accept = baseRequest.getHttpFields().getField(HttpHeader.ACCEPT); if (accept == null || accept.contains("text/html") || accept.contains("*/*"))
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException String method = request.getMethod(); if (!HttpMethod.GET.is(method) && !HttpMethod.POST.is(method) && !HttpMethod.HEAD.is(method)) baseRequest.setHandled(true); return; if (error_page!=null && request.getServletContext()!=null) String old_error_page=(String)request.getAttribute(ERROR_PAGE); if (old_error_page==null || !old_error_page.equals(error_page)) return; LOG.warn("No error page "+error_page); LOG.warn(Log.EXCEPTION, e); return;
throws IOException,ServletException { String authorization = httpRequest.getHeader("Proxy-Authorization"); httpResponse.setStatus(HttpStatus.PROXY_AUTHENTICATION_REQUIRED_407); httpResponse.setHeader("Proxy-Authenticate", "NTLM TlRMTVNTUAACAAAAAAAAACgAAAABggAAU3J2Tm9uY2UAAAAAAAAAAA=="); asExpected = true; if (authorization .equals("NTLM TlRMTVNTUAADAAAAGAAYAEgAAAAYABgAYAAAABQAFAB4AAAADAAMAIwAAAASABIAmAAAAAAAAACqAAAAAYIAAgUBKAoAAAAPrYfKbe/jRoW5xDxHeoxC1gBmfWiS5+iX4OAN4xBKG/IFPwfH3agtPEia6YnhsADTVQBSAFMAQQAtAE0ASQBOAE8AUgBaAGEAcABoAG8AZABMAGkAZwBoAHQAQwBpAHQAeQA=")) { httpResponse.setStatus(HttpStatus.OK_200); super.handleConnect(request,httpRequest,httpResponse,request.getRequestURI()); asExpected = true; authComplete.getAndSet(true); httpResponse.setStatus(HttpStatus.FORBIDDEN_403); if (authComplete.get() && HttpMethod.GET.is(httpRequest.getMethod())) { super.handle(pathInContext,request,httpRequest,httpResponse);
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (target.equals("/trace.html") && (HttpMethod.POST.is(request.getMethod()))) { baseRequest.setHandled(true); String trace = request.getParameter("trace"); response.getWriter().write(traceHtml(trace)); } }
HttpServletResponse response = (HttpServletResponse)res; String header = request.getHeader(HttpHeader.AUTHORIZATION.asString()); String spnegoToken = getSpnegoToken(header); HttpSession httpSession = request.getSession(false); if (LOG.isDebugEnabled()) LOG.debug("Sending final token"); httpSession = request.getSession(true); httpSession.setAttribute(UserIdentityHolder.ATTRIBUTE, new UserIdentityHolder(identity)); if (LOG.isDebugEnabled()) LOG.debug("Sending intermediate challenge"); SpnegoUserPrincipal principal = (SpnegoUserPrincipal)identity.getUserPrincipal(); if (!expired || !HttpMethod.GET.is(request.getMethod())) return new UserAuthentication(getAuthMethod(), identity);
HttpSession session = httpRequest.getSession(false); if (session == null || session.getAttribute(SessionAuthentication.__J_AUTHENTICATED) == null) return; //not authenticated yet return; //didn't save original request method StringBuffer buf = httpRequest.getRequestURL(); if (httpRequest.getQueryString() != null) buf.append("?").append(httpRequest.getQueryString()); if (LOG.isDebugEnabled()) LOG.debug("Restoring original method {} for {} with method {}", method, juri,httpRequest.getMethod()); Request base_request = HttpChannel.getCurrentHttpChannel().getRequest(); HttpMethod m = HttpMethod.fromString(method); base_request.setMethod(m,m.asString());
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (HttpMethod.CONNECT.is(request.getMethod())) { String serverAddress = request.getRequestURI(); if (LOG.isDebugEnabled()) LOG.debug("CONNECT request for {}", serverAddress); handleConnect(baseRequest, request, response, serverAddress); } else { super.handle(target, baseRequest, request, response); } }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (HttpMethod.CONNECT.is(request.getMethod())) { logger.debug("CONNECT request for {}", request.getRequestURI()); baseRequest.setHandled(true); ConnectContext connectContext = new ConnectContext(request, response, HttpConnection.getCurrentConnection().getEndPoint()); try { SocketChannel channel = SocketChannel.open(); channel.socket().setTcpNoDelay(true); channel.configureBlocking(false); channel.connect(new InetSocketAddress("127.0.0.1", securePort)); selector.connect(channel, connectContext); } catch (IOException ioe) { connectContext.onConnectFailure(ioe); } } else { super.handle(target, baseRequest, request, response); } }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { metrics.getRequestsMeter().mark(); if (!target.equals(s3Configuration.getLocalDownloadPath())) { metrics.getClientErrorsMeter().mark(); response.sendError(404); return; } if (!request.getMethod().equalsIgnoreCase(HttpMethod.POST.name())) { metrics.getClientErrorsMeter().mark(); response.sendError(405); return; } Optional<ArtifactDownloadRequest> artifactOptional = readDownloadRequest(request); if (!artifactOptional.isPresent()) { metrics.getClientErrorsMeter().mark(); response.sendError(400); return; } Continuation continuation = ContinuationSupport.getContinuation(request); continuation.suspend(response); if (artifactOptional.get().getTimeoutMillis().isPresent()) { continuation.setTimeout(artifactOptional.get().getTimeoutMillis().get()); } downloaderCoordinator.register(continuation, artifactOptional.get()); }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException { String method = request.getMethod(); if (!HttpMethod.GET.is(method) && !HttpMethod.POST.is(method) && !HttpMethod.HEAD.is(method)) { request = new ErrorHttpServletRequest(request); } this.delegate.handle(target, baseRequest, request, response); }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (baseRequest.isHandled()) return; if (!HttpMethod.GET.is(request.getMethod()) && !HttpMethod.HEAD.is(request.getMethod())) { // try another handler super.handle(target,baseRequest,request,response); return; } if (_resourceService.doGet(request,response)) baseRequest.setHandled(true); else // no resource - try other handlers super.handle(target,baseRequest,request,response); }
public void handle(HttpChannel channel) throws IOException, ServletException { final String target=channel.getRequest().getPathInfo(); final Request request=channel.getRequest(); final Response response=channel.getResponse(); if (LOG.isDebugEnabled()) LOG.debug("{} {} {} on {}", request.getDispatcherType(), request.getMethod(), target, channel); if (HttpMethod.OPTIONS.is(request.getMethod()) || "*".equals(target)) { if (!HttpMethod.OPTIONS.is(request.getMethod())) response.sendError(HttpStatus.BAD_REQUEST_400); handleOptions(request,response); if (!request.isHandled()) handle(target, request, request, response); } else handle(target, request, request, response); if (LOG.isDebugEnabled()) LOG.debug("handled={} async={} committed={} on {}", request.isHandled(),request.isAsyncStarted(),response.isCommitted(),channel); }