Search in sources :

Example 1 with RedirectResponse

use of org.webpieces.router.impl.dto.RedirectResponse in project webpieces by deanhiller.

the class ProxyStreamHandle method sendRedirectAndClearCookie.

public XFuture<StreamWriter> sendRedirectAndClearCookie(RouterRequest req, String badCookieName) {
    RedirectResponse httpResponse = new RedirectResponse(false, req.isHttps, req.domain, req.port, req.relativePath);
    Http2Response response = responseCreator.createRedirect(originalHttp2Request, httpResponse);
    responseCreator.addDeleteCookie(response, badCookieName);
    log.info("sending REDIRECT(due to bad cookie) response responseSender=" + this);
    return process(response);
}
Also used : Http2Response(com.webpieces.http2.api.dto.highlevel.Http2Response) RedirectResponse(org.webpieces.router.impl.dto.RedirectResponse)

Example 2 with RedirectResponse

use of org.webpieces.router.impl.dto.RedirectResponse in project webpieces by deanhiller.

the class ResponseProcessorHtml method createRawRedirect.

public XFuture<Void> createRawRedirect(MethodMeta meta, RawRedirect controllerResponse, ProxyStreamHandle handle) {
    RequestContext ctx = meta.getCtx();
    String url = controllerResponse.getUrl();
    if (url.startsWith("http")) {
        return handle.sendRedirect(new RedirectResponse(url));
    }
    RouterRequest request = ctx.getRequest();
    RedirectResponse redirectResponse = new RedirectResponse(false, request.isHttps, request.domain, request.port, url);
    return handle.sendRedirect(redirectResponse);
}
Also used : RedirectResponse(org.webpieces.router.impl.dto.RedirectResponse) RequestContext(org.webpieces.ctx.api.RequestContext) RouterRequest(org.webpieces.ctx.api.RouterRequest)

Example 3 with RedirectResponse

use of org.webpieces.router.impl.dto.RedirectResponse in project webpieces by deanhiller.

the class ProxyStreamHandle method createRedirect.

private XFuture<Void> createRedirect(HttpPort requestedPort, RouteId id, Map<String, Object> args, boolean isAjaxRedirect) {
    if (methodMeta == null) {
        throw new IllegalStateException("Somehow methodMeta is missing.  This method should only be called from filters and controllers");
    }
    RequestContext ctx = methodMeta.getCtx();
    RouterRequest request = ctx.getRequest();
    Method method = methodMeta.getLoadedController().getControllerMethod();
    UrlInfo urlInfo = reverseRoutes.routeToUrl(id, method, args, ctx, requestedPort);
    boolean isSecure = urlInfo.isSecure();
    int port = urlInfo.getPort();
    String path = urlInfo.getPath();
    RedirectResponse redirectResponse = new RedirectResponse(isAjaxRedirect, isSecure, request.domain, port, path);
    return sendRedirect(redirectResponse);
}
Also used : UrlInfo(org.webpieces.router.impl.UrlInfo) RedirectResponse(org.webpieces.router.impl.dto.RedirectResponse) RequestContext(org.webpieces.ctx.api.RequestContext) Method(java.lang.reflect.Method) RouterRequest(org.webpieces.ctx.api.RouterRequest)

Aggregations

RedirectResponse (org.webpieces.router.impl.dto.RedirectResponse)3 RequestContext (org.webpieces.ctx.api.RequestContext)2 RouterRequest (org.webpieces.ctx.api.RouterRequest)2 Http2Response (com.webpieces.http2.api.dto.highlevel.Http2Response)1 Method (java.lang.reflect.Method)1 UrlInfo (org.webpieces.router.impl.UrlInfo)1