Search in sources :

Example 1 with ResponseEncodingTuple

use of org.webpieces.router.impl.proxyout.ResponseCreator.ResponseEncodingTuple in project webpieces by deanhiller.

the class ProxyStreamHandle method createResponseAndSend.

public XFuture<Void> createResponseAndSend(Http2Request request, StatusCode statusCode, String content, String extension, String defaultMime) {
    if (content == null)
        throw new IllegalArgumentException("content cannot be null");
    ResponseEncodingTuple tuple = responseCreator.createResponse(request, statusCode, extension, defaultMime, true);
    if (log.isDebugEnabled())
        log.debug("content about to be sent back=" + content);
    Charset encoding = tuple.mimeType.htmlResponsePayloadEncoding;
    byte[] bytes = content.getBytes(encoding);
    return maybeCompressAndSend(request, extension, tuple, bytes);
}
Also used : ResponseEncodingTuple(org.webpieces.router.impl.proxyout.ResponseCreator.ResponseEncodingTuple) Charset(java.nio.charset.Charset)

Example 2 with ResponseEncodingTuple

use of org.webpieces.router.impl.proxyout.ResponseCreator.ResponseEncodingTuple in project webpieces by deanhiller.

the class ProxyStreamHandle method sendRenderContent.

public XFuture<Void> sendRenderContent(RenderContentResponse resp) {
    Http2Request request = originalHttp2Request;
    ResponseEncodingTuple tuple = responseCreator.createContentResponse(request, resp.getStatusCode(), resp.getReason(), resp.getMimeType());
    return maybeCompressAndSend(request, null, tuple, resp.getPayload());
}
Also used : ResponseEncodingTuple(org.webpieces.router.impl.proxyout.ResponseCreator.ResponseEncodingTuple) Http2Request(com.webpieces.http2.api.dto.highlevel.Http2Request)

Aggregations

ResponseEncodingTuple (org.webpieces.router.impl.proxyout.ResponseCreator.ResponseEncodingTuple)2 Http2Request (com.webpieces.http2.api.dto.highlevel.Http2Request)1 Charset (java.nio.charset.Charset)1