Example usage for com.google.gwt.user.server.rpc RPCServletUtils exceedsUncompressedContentLengthLimit

List of usage examples for com.google.gwt.user.server.rpc RPCServletUtils exceedsUncompressedContentLengthLimit

Introduction

In this page you can find the example usage for com.google.gwt.user.server.rpc RPCServletUtils exceedsUncompressedContentLengthLimit.

Prototype

public static boolean exceedsUncompressedContentLengthLimit(String content) 

Source Link

Document

Returns true if the response content's estimated UTF-8 byte length exceeds 256 bytes.

Usage

From source file:com.brightedu.server.BrightServlet.java

License:Apache License

/**
 * Determines whether the response to a given servlet request should or
 * should not be GZIP compressed. This method is only called in cases where
 * the requester accepts GZIP encoding.//from  ww  w . ja  v  a2 s.co m
 * <p>
 * This implementation currently returns <code>true</code> if the response
 * string's estimated byte length is longer than 256 bytes. Subclasses can
 * override this logic.
 * </p>
 * 
 * @param request
 *            the request being served
 * @param response
 *            the response that will be written into
 * @param responsePayload
 *            the payload that is about to be sent to the client
 * @return <code>true</code> if responsePayload should be GZIP compressed,
 *         otherwise <code>false</code>.
 */
protected boolean shouldCompressResponse(HttpServletRequest request, HttpServletResponse response,
        String responsePayload) {
    return RPCServletUtils.exceedsUncompressedContentLengthLimit(responsePayload);
}

From source file:com.openforevent.gwt.gwtrpc.server.GwtRpcServiceImpl.java

License:Apache License

protected boolean shouldCompressResponse(HttpServletRequest request, HttpServletResponse response,
        String responsePayload) {
    return RPCServletUtils.exceedsUncompressedContentLengthLimit(responsePayload);
}

From source file:de.itsvs.cwtrpc.controller.RemoteServiceControllerServlet.java

License:Apache License

protected void writeResponse(HttpServletRequest request, HttpServletResponse response,
        PreparedRemoteServiceConfig serviceConfig, String payload) throws IOException {
    final boolean gzipResponse;

    gzipResponse = serviceConfig.isResponseCompressionEnabled() && RPCServletUtils.acceptsGzipEncoding(request)
            && RPCServletUtils.exceedsUncompressedContentLengthLimit(payload);

    if (log.isDebugEnabled()) {
        log.debug("Writing response (gzip=" + gzipResponse + ")");
    }//from w w  w.j  a v a  2  s .  c om
    addNoCacheResponseHeaders(request, response);
    RPCServletUtils.writeResponse(getServletContext(), response, payload, gzipResponse);
    /*
     * Flush all remaining output to the client (client can continue
     * immediately). Also response will be marked as being committed (status
     * may be required later by a filter).
     */
    response.flushBuffer();
}

From source file:fr.putnami.pwt.core.service.server.service.AbstractCommandService.java

License:Open Source License

@Override
protected void processPost(HttpServletRequest request, HttpServletResponse response) throws Throwable {
    try {//from  w w w  .  java2s  .co m
        String requestPayload = this.readContent(request);
        RPCRequest rpcRequest = RPC.decodeRequest(requestPayload, getClass(), this);

        String responsePayload = RPC.invokeAndEncodeResponse(this, rpcRequest.getMethod(),
                rpcRequest.getParameters(), rpcRequest.getSerializationPolicy(), rpcRequest.getFlags());

        boolean gzipEncode = RPCServletUtils.acceptsGzipEncoding(request)
                && RPCServletUtils.exceedsUncompressedContentLengthLimit(responsePayload);

        RPCServletUtils.writeResponse(null, response, responsePayload, gzipEncode);
    } catch (Exception e) {
        logger.error("Request processing failed", e);
        throw Throwables.propagate(e);
    }
}

From source file:fr.putnami.pwt.core.service.server.service.BasicCommandService.java

License:Open Source License

@Override
protected void processPost(HttpServletRequest request, HttpServletResponse response) throws Throwable {
    try {// w ww  .  ja v a  2 s . c o m
        String requestPayload = this.readContent(request);
        RPCRequest rpcRequest = RPC.decodeRequest(requestPayload, this.getClass(), this);

        String responsePayload = RPC.invokeAndEncodeResponse(this, rpcRequest.getMethod(),
                rpcRequest.getParameters(), rpcRequest.getSerializationPolicy(), rpcRequest.getFlags());

        boolean gzipEncode = RPCServletUtils.acceptsGzipEncoding(request)
                && RPCServletUtils.exceedsUncompressedContentLengthLimit(responsePayload);

        RPCServletUtils.writeResponse(null, response, responsePayload, gzipEncode);
    } catch (Exception e) {
        this.logger.error("Request processing failed", e);
        throw Throwables.propagate(e);
    }
}

From source file:fr.putnami.pwt.plugin.spring.rpc.server.controller.CommandController.java

License:Open Source License

@RequestMapping(value = "/commandService", method = RequestMethod.POST)
public void processPostRpc(HttpServletRequest request, HttpServletResponse response) throws Throwable {
    try {//from www.  j av a 2  s .c om
        String requestPayload = RPCServletUtils.readContentAsGwtRpc(request);
        RPCRequest rpcRequest = RPC.decodeRequest(requestPayload, CommandService.class, this);

        String responsePayload = RPC.invokeAndEncodeResponse(commandService, rpcRequest.getMethod(),
                rpcRequest.getParameters(), rpcRequest.getSerializationPolicy(), rpcRequest.getFlags());

        boolean gzipEncode = RPCServletUtils.acceptsGzipEncoding(request)
                && RPCServletUtils.exceedsUncompressedContentLengthLimit(responsePayload);

        RPCServletUtils.writeResponse(null, response, responsePayload, gzipEncode);
    } catch (Exception e) {
        this.logger.error("Request processing failed", e);
        throw Throwables.propagate(e);
    }
}

From source file:org.atmosphere.gwt.poll.AtmospherePollService.java

License:Apache License

/**
 * Determines whether the response to a given servlet request should or should
 * not be GZIP compressed. This method is only called in cases where the
 * requester accepts GZIP encoding./*from w  ww  .j a v a  2  s .  c  om*/
 * <p>
 * This implementation currently returns <code>true</code> if the response
 * string's estimated byte length is longer than 256 bytes. Subclasses can
 * override this logic.
 * </p>
 *
 * @param request the request being served
 * @param response the response that will be written into
 * @param responsePayload the payload that is about to be sent to the client
 * @return <code>true</code> if responsePayload should be GZIP compressed,
 *         otherwise <code>false</code>.
 */
protected static boolean shouldCompressResponse(HttpServletRequest request, HttpServletResponse response,
        String responsePayload) {
    return RPCServletUtils.exceedsUncompressedContentLengthLimit(responsePayload);
}