use of org.apache.servicecomb.foundation.vertx.stream.BufferOutputStream in project incubator-servicecomb-java-chassis by apache.
the class ServerRestArgsFilter method beforeSendResponse.
@Override
public void beforeSendResponse(Invocation invocation, HttpServletResponseEx responseEx) {
Response response = (Response) responseEx.getAttribute(RestConst.INVOCATION_HANDLER_RESPONSE);
ProduceProcessor produceProcessor = (ProduceProcessor) responseEx.getAttribute(RestConst.INVOCATION_HANDLER_PROCESSOR);
Object body = response.getResult();
if (response.isFailed()) {
body = ((InvocationException) body).getErrorData();
}
try (BufferOutputStream output = new BufferOutputStream(Unpooled.compositeBuffer())) {
produceProcessor.encodeResponse(output, body);
responseEx.setBodyBuffer(output.getBuffer());
} catch (Throwable e) {
throw ExceptionFactory.convertProducerException(e);
}
}
use of org.apache.servicecomb.foundation.vertx.stream.BufferOutputStream in project incubator-servicecomb-java-chassis by apache.
the class TestResultSerializer method setUp.
@Before
public void setUp() throws Exception {
resultSerializer = new ResultSerializer();
outputStream = new BufferOutputStream();
}
Aggregations