Search in sources :

Example 1 with RequestImpl

use of org.apache.tapestry5.http.internal.services.RequestImpl in project flowlogix by flowlogix.

the class GwtCachingFilter method service.

@Override
public boolean service(HttpServletRequest request, HttpServletResponse response, HttpServletRequestHandler chainHandler) throws IOException {
    String path = request.getServletPath();
    boolean neverExpire = checkConfig(path, response);
    if (neverExpire == false) {
        return chainHandler.service(request, response);
    }
    log.finer("GwtCachingFilter: Processing " + path);
    Request rq = new RequestImpl(request, applicationCharset, sessionFactory);
    Response rsp = new ResponseImpl(request, response);
    rg.storeRequestResponse(rq, rsp);
    rsp.setDateHeader("Expires", new Date().getTime() + InternalConstants.TEN_YEARS);
    try {
        return carh.handleAssetRequest(rq, rsp, pathProcessor.removeAssetPathPart(path));
    } catch (Exception e) {
        return chainHandler.service(request, response);
    }
}
Also used : Response(org.apache.tapestry5.services.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tapestry5.services.Request) RequestImpl(org.apache.tapestry5.internal.services.RequestImpl) ResponseImpl(org.apache.tapestry5.internal.services.ResponseImpl) Date(java.util.Date) IOException(java.io.IOException)

Example 2 with RequestImpl

use of org.apache.tapestry5.http.internal.services.RequestImpl in project tapestry-5 by apache.

the class RequestImplTest method used_encoding_from_request.

@Test
public void used_encoding_from_request() throws Exception {
    HttpServletRequest sr = mockHttpServletRequest();
    expect(sr.getCharacterEncoding()).andReturn("request-encoding");
    sr.setCharacterEncoding("request-encoding");
    expect(sr.getParameterNames()).andReturn(Collections.enumeration(Collections.EMPTY_LIST));
    replay();
    new RequestImpl(sr, "app-encoding-is-ignored", null).getParameterNames();
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RequestImpl(org.apache.tapestry5.http.internal.services.RequestImpl) Test(org.testng.annotations.Test)

Example 3 with RequestImpl

use of org.apache.tapestry5.http.internal.services.RequestImpl in project tapestry-5 by apache.

the class RequestImplTest method set_encoding_failure.

@Test
public void set_encoding_failure() throws Exception {
    HttpServletRequest sr = mockHttpServletRequest();
    String encoding = "the-encoding";
    UnsupportedEncodingException exception = new UnsupportedEncodingException("Oops.");
    sr.setCharacterEncoding(encoding);
    setThrowable(exception);
    expect(sr.getCharacterEncoding()).andReturn(null);
    replay();
    try {
        new RequestImpl(sr, encoding, null).getParameterNames();
        unreachable();
    } catch (RuntimeException ex) {
        assertSame(ex.getCause(), exception);
    }
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) UnsupportedEncodingException(java.io.UnsupportedEncodingException) RequestImpl(org.apache.tapestry5.http.internal.services.RequestImpl) Test(org.testng.annotations.Test)

Example 4 with RequestImpl

use of org.apache.tapestry5.http.internal.services.RequestImpl in project tapestry-5 by apache.

the class RequestImplTest method request_secure_with_x_forwarded_proto.

@Test
public void request_secure_with_x_forwarded_proto() throws Exception {
    HttpServletRequest sr = mockHttpServletRequest();
    expect(sr.isSecure()).andReturn(false);
    expect(sr.getHeader(Request.X_FORWARDED_PROTO_HEADER)).andReturn("https");
    replay();
    Request request = new RequestImpl(sr, CHARSET, null);
    assertTrue(request.isSecure());
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tapestry5.http.services.Request) RequestImpl(org.apache.tapestry5.http.internal.services.RequestImpl) Test(org.testng.annotations.Test)

Example 5 with RequestImpl

use of org.apache.tapestry5.http.internal.services.RequestImpl in project tapestry-5 by apache.

the class RequestImplTest method get_session_doesnt_exist.

@Test
public void get_session_doesnt_exist() {
    HttpServletRequest sr = mockHttpServletRequest();
    TapestrySessionFactory sf = newMock(TapestrySessionFactory.class);
    expect(sf.getSession(false)).andReturn(null);
    replay();
    Request request = new RequestImpl(sr, CHARSET, sf);
    assertNull(request.getSession(false));
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TapestrySessionFactory(org.apache.tapestry5.http.internal.services.TapestrySessionFactory) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tapestry5.http.services.Request) RequestImpl(org.apache.tapestry5.http.internal.services.RequestImpl) Test(org.testng.annotations.Test)

Aggregations

HttpServletRequest (javax.servlet.http.HttpServletRequest)14 RequestImpl (org.apache.tapestry5.http.internal.services.RequestImpl)13 Test (org.testng.annotations.Test)13 Request (org.apache.tapestry5.http.services.Request)10 TapestrySessionFactory (org.apache.tapestry5.http.internal.services.TapestrySessionFactory)5 HttpSession (javax.servlet.http.HttpSession)3 Session (org.apache.tapestry5.http.services.Session)3 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Date (java.util.Date)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 RequestImpl (org.apache.tapestry5.internal.services.RequestImpl)1 ResponseImpl (org.apache.tapestry5.internal.services.ResponseImpl)1 Request (org.apache.tapestry5.services.Request)1 Response (org.apache.tapestry5.services.Response)1