@Override @SuppressWarnings("unchecked") public T parse(ServerHttpConnection connection) throws HttpException { try { return (T) mapper.readValue(connection.getRequest().getEntity(), javaType); } catch (IOException ex) { throw new HttpException(ex); } } };
HttpHeader header = request.getHeaders().getHeader("authorization"); if (header != null) { authenticate = header.getValue();
/** * Services the {@link HttpRequest}. * * @param connection * {@link ServerHttpConnection}. * @param managedFunctionContext * {@link ManagedFunctionContext}. * @return <code>true</code> if {@link HttpRequest} was routed to a * {@link WebRouteHandler}. <code>false</code> indicates not * handled. */ public boolean service(ServerHttpConnection connection, ManagedFunctionContext<?, Indexed> managedFunctionContext) { // Obtain the request details HttpRequest request = connection.getRequest(); HttpMethod method = request.getMethod(); String requestUri = request.getUri(); // Attempt to match to a route for (int i = 0; i < this.nodes.length; i++) { WebRouteNode node = this.nodes[i]; // Determine if handled by node if (node.handle(method, requestUri, 0, null, connection, managedFunctionContext)) { return true; // servicing request } } // As here, not handling request return false; }
String requestUri = request.getUri(); for (HttpHeader header : request.getHeaders()) { name = header.getName(); value = header.getValue();
@Override public String extractApplicationPath(ServerHttpConnection connection) throws HttpException { return WebRouter.transformToApplicationCanonicalPath(connection.getRequest().getUri(), this.contextPath); }
@Override public void loadObjects(ObjectRegistry<Indexed> registry) throws Throwable { // Obtain the HTTP request this.connection = (ServerHttpConnection) registry.getObject(this.serverHttpConnectionIndex); HttpRequest request = this.connection.getRequest(); // Ensure have the HTTP session Id generator if (this.httpSessionIdGenerator == null) { this.httpSessionIdGenerator = (HttpSessionIdGenerator) registry.getObject(this.httpSessionIdGeneratorIndex); } // Ensure have the HTTP session store if (this.httpSessionStore == null) { this.httpSessionStore = (HttpSessionStore) registry.getObject(this.httpSessionStoreIndex); } // Obtain the Session Id from the Session cookie HttpRequestCookie sessionIdCookie = request.getCookies().getCookie(this.sessionIdCookieName); String sessionId = (sessionIdCookie == null ? null : sessionIdCookie.getValue()); // Handle based on Session Id being available if ((sessionId == null) || (sessionId.trim().length() == 0)) { // No established session so create a new session this.generateSessionId(); } else { // Retrieve the existing session this.loadSessionId(sessionId, false); } }
@Override public Object execute(ManagedFunctionContext<NotFoundDependencies, None> context) throws NotFoundHttpException { // Obtain the request path ServerHttpConnection connection = (ServerHttpConnection) context .getObject(NotFoundDependencies.SERVER_HTTP_CONNECTION); String requestPath = connection.getRequest().getUri(); // Not found throw new NotFoundHttpException(requestPath); }
@Override public void loadValues(ValueLoader valueLoader) throws HttpException { this.context.run(() -> { // Tokenise the HTTP request HttpRequest request = this.ensureTokenised(); // Load the arguments HttpArgument argument = this.arguments; while (argument != null) { valueLoader.loadValue(argument.name, argument.value, argument.location); argument = argument.next; } // Always load cookies from request for (HttpRequestCookie cookie : request.getCookies()) { valueLoader.loadValue(cookie.getName(), cookie.getValue(), HttpValueLocation.COOKIE); } // Void return return null; }); }
String path = connection.getRequest().getUri(); int endPathIndex = path.indexOf('?'); if (endPathIndex >= 0) {
Reader reader = new InputStreamReader(request.getEntity().createBrowseInputStream(), ServerHttpConnection.DEFAULT_HTTP_ENTITY_CHARSET); for (int character = reader.read(); character != -1; character = reader.read()) {
HttpRequestHeaders headers = request.getHeaders(); for (HttpHeader header : headers.getHeaders("accept")) { head = parseAccept(header.getValue(), head);
@Override public Object execute(ManagedFunctionContext<HttpRouteDependencies, Indexed> context) { // Obtain the server HTTP connection ServerHttpConnection connection = (ServerHttpConnection) context .getObject(HttpRouteDependencies.SERVER_HTTP_CONNECTION); // Load the escalation handler if (this.escalationHandler != null) { connection.getResponse().setEscalationHandler(this.escalationHandler); } // Determine if potentially redirect HttpRequestCookie cookie = connection.getRequest().getCookies() .getCookie(HttpRedirectFunction.REDIRECT_COOKIE_NAME); if (cookie != null) { // Redirect, so trigger flow to import previous state context.doFlow(this.handleRedirectFlowIndex, cookie, null); return null; // serviced by redirect } // No redirect, so route the request return this.router.route(connection, context); }
@Override public void handle(HttpArgument pathArguments, ServerHttpConnection connection, ManagedFunctionContext<?, Indexed> context) { // Determine if secure connection is required if (this.isRequireSecure && (!connection.isSecure())) { // Non-secure, requiring secure - so redirect String path = connection.getRequest().getUri(); String securePath = connection.getServerLocation().createClientUrl(this.isRequireSecure, path); // Send redirect response to secure path HttpResponse response = connection.getResponse(); response.setStatus(HttpStatus.TEMPORARY_REDIRECT); response.getHeaders().addHeader(LOCATION, securePath); return; } // Undertake flow to service route context.doFlow(this.flowIndex, pathArguments, null); }
for (HttpHeader header : request.getHeaders()) { if ("ETag".equalsIgnoreCase(header.getName())) { eTag = header.getValue();
String uri = request.getUri(); if (!(this.inputPath.isMatchPath(uri, this.terminatingPathCharacter))) {