Search in sources :

Example 1 with PlainBodyTransferrer

use of com.predic8.membrane.core.http.PlainBodyTransferrer in project service-proxy by membrane.

the class HttpServletHandler method writeResponse.

@SuppressWarnings("deprecation")
protected void writeResponse(Response res) throws Exception {
    response.setStatus(res.getStatusCode(), res.getStatusMessage());
    for (HeaderField header : res.getHeader().getAllHeaderFields()) {
        if (header.getHeaderName().equals(Header.TRANSFER_ENCODING))
            continue;
        response.addHeader(header.getHeaderName().toString(), header.getValue());
    }
    ServletOutputStream out = response.getOutputStream();
    res.getBody().write(new PlainBodyTransferrer(out));
    out.flush();
    response.flushBuffer();
    exchange.setTimeResSent(System.currentTimeMillis());
    exchange.collectStatistics();
}
Also used : HeaderField(com.predic8.membrane.core.http.HeaderField) ServletOutputStream(javax.servlet.ServletOutputStream) PlainBodyTransferrer(com.predic8.membrane.core.http.PlainBodyTransferrer)

Aggregations

HeaderField (com.predic8.membrane.core.http.HeaderField)1 PlainBodyTransferrer (com.predic8.membrane.core.http.PlainBodyTransferrer)1 ServletOutputStream (javax.servlet.ServletOutputStream)1