/** * Loads the {@link HttpChallenge} to the {@link HttpResponse}. * * @param httpChallengeContext * {@link HttpChallengeContext}. * @param response * {@link HttpResponse}. */ public static void loadHttpChallenge(HttpChallengeContext httpChallengeContext, HttpResponse response) { // Obtain the challenge HttpChallengeContextManagedObject managedObject = (HttpChallengeContextManagedObject) httpChallengeContext; // Determine if challenge and if so send challenge managedObject.processAwareContext.run(() -> { if (managedObject.challenge.length() > 0) { response.setStatus(HttpStatus.UNAUTHORIZED); response.getHeaders().addHeader(CHALLENGE_NAME, managedObject.challenge.toString()); } return null; }); }
response.setStatus(HttpStatus.METHOD_NOT_ALLOWED); response.getHeaders().addHeader(ALLOW, this.allowedMethods);
@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); }
response.setStatus(HttpStatus.SEE_OTHER); response.getHeaders().addHeader(LOCATION, redirectLocation);