Search in sources :

Example 1 with IHttpServletRequest

use of com.genexus.servlet.http.IHttpServletRequest in project JavaClasses by genexuslabs.

the class GXWebObjectStub method dumpRequestInfo.

private void dumpRequestInfo(HttpContext httpContext) {
    IHttpServletRequest request = httpContext.getRequest();
    StringBuffer sBuffer = new StringBuffer();
    String nl = System.getProperty("line.separator");
    sBuffer.append("Request Information");
    sBuffer.append(nl + "Url: ");
    sBuffer.append(request.getRequestURL());
    sBuffer.append(nl + "HttpHeaders: " + nl);
    for (Enumeration<String> headerNames = request.getHeaderNames(); headerNames.hasMoreElements(); ) {
        String header = headerNames.nextElement();
        sBuffer.append(header);
        sBuffer.append(":");
        sBuffer.append(request.getHeader(header));
    }
    sBuffer.append(nl + "HttpCookies: " + nl);
    ICookie[] cookies = httpContext.getCookies();
    if (cookies != null) {
        for (int i = 0; i < cookies.length; i++) {
            sBuffer.append(cookies[i].getName());
            sBuffer.append(":");
            sBuffer.append(cookies[i].getValue());
        }
    }
    logger.debug(sBuffer.toString());
}
Also used : IHttpServletRequest(com.genexus.servlet.http.IHttpServletRequest) ICookie(com.genexus.servlet.http.ICookie)

Example 2 with IHttpServletRequest

use of com.genexus.servlet.http.IHttpServletRequest in project JavaClasses by genexuslabs.

the class CustomFilter method doFilter.

public void doFilter(IServletRequest request, IServletResponse response, IFilterChain chain) throws Exception {
    if (request != null && request.isHttpServletRequest()) {
        IHttpServletRequest req = request.getHttpServletRequest();
        String url = req.getRequestURL().toString();
        if (url.contains("apple-app-site-association")) {
            IHttpServletResponse resp = response.getHttpServletResponse();
            resp.setContentType("application/json");
        }
    }
    // pass the request along the filter chain
    chain.doFilter(request, response);
}
Also used : IHttpServletRequest(com.genexus.servlet.http.IHttpServletRequest) IHttpServletResponse(com.genexus.servlet.http.IHttpServletResponse)

Example 3 with IHttpServletRequest

use of com.genexus.servlet.http.IHttpServletRequest in project JavaClasses by genexuslabs.

the class InternalRestServicesFilter method doFilter.

public void doFilter(IServletRequest request, IServletResponse response, IFilterChain chain) throws Exception {
    if (request.isHttpServletRequest() && response.isHttpServletResponse()) {
        IHttpServletRequest httpRequest = request.getHttpServletRequest();
        String path = httpRequest.getRequestURI().substring(httpRequest.getContextPath().length()).substring(1);
        String urlString = (path.lastIndexOf("/") > -1) ? path.substring(0, path.lastIndexOf("/")).toLowerCase() : path.toLowerCase();
        boolean isPath = appPath.contains(urlString);
        if (isPath) {
            String fwdURI = "/rest/" + path;
            httpRequest.getRequestDispatcher(fwdURI).forward(request, response);
        } else {
            chain.doFilter(request, response);
        }
    } else {
        chain.doFilter(request, response);
    }
}
Also used : IHttpServletRequest(com.genexus.servlet.http.IHttpServletRequest)

Example 4 with IHttpServletRequest

use of com.genexus.servlet.http.IHttpServletRequest in project JavaClasses by genexuslabs.

the class WebWrapper method setSource.

public void setSource(GXWebPanel panel) {
    this.panel = panel;
    ModelContext context = panel.getModelContext();
    HttpRequest httpReq = ((HttpContext) context.getHttpContext()).getHttpRequest();
    IHttpServletRequest httpSerReq = ((HttpContext) context.getHttpContext()).getRequest();
    context.setHttpContext(new HttpContextNull());
    ((HttpContext) context.getHttpContext()).setHttpRequest(httpReq);
    ((HttpContext) context.getHttpContext()).setRequest(httpSerReq);
    ((HttpContext) context.getHttpContext()).setContext(context);
    panel.setHttpContext(((HttpContext) context.getHttpContext()));
    panel.getHttpContext().setCompression(false);
    panel.getHttpContext().setBuffered(false);
    panel.getHttpContext().useUtf8 = true;
    panel.getHttpContext().setOutputStream(new java.io.ByteArrayOutputStream());
}
Also used : ModelContext(com.genexus.ModelContext) HttpRequest(com.genexus.internet.HttpRequest) IHttpServletRequest(com.genexus.servlet.http.IHttpServletRequest) ByteArrayOutputStream(java.io.ByteArrayOutputStream) HttpContext(com.genexus.internet.HttpContext) HttpContextNull(com.genexus.internet.HttpContextNull)

Example 5 with IHttpServletRequest

use of com.genexus.servlet.http.IHttpServletRequest in project JavaClasses by genexuslabs.

the class APIObjectFilter method doFilter.

public void doFilter(IServletRequest request, IServletResponse response, IFilterChain chain) throws Exception {
    if (request.isHttpServletRequest() && response.isHttpServletResponse()) {
        IHttpServletRequest httpRequest = request.getHttpServletRequest();
        String path = httpRequest.getRequestURI().substring(httpRequest.getContextPath().length()).substring(1);
        String urlString = path.toLowerCase();
        boolean isPath = false;
        for (String appBasePath : appPath) {
            if (urlString.startsWith(appBasePath)) {
                isPath = true;
                break;
            }
        }
        if (isPath) {
            String fwdURI = "/rest/" + path;
            httpRequest.getRequestDispatcher(fwdURI).forward(request, response);
        } else {
            chain.doFilter(request, response);
        }
    } else {
        chain.doFilter(request, response);
    }
}
Also used : IHttpServletRequest(com.genexus.servlet.http.IHttpServletRequest)

Aggregations

IHttpServletRequest (com.genexus.servlet.http.IHttpServletRequest)5 ModelContext (com.genexus.ModelContext)1 HttpContext (com.genexus.internet.HttpContext)1 HttpContextNull (com.genexus.internet.HttpContextNull)1 HttpRequest (com.genexus.internet.HttpRequest)1 ICookie (com.genexus.servlet.http.ICookie)1 IHttpServletResponse (com.genexus.servlet.http.IHttpServletResponse)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1