* {@inheritDoc}
*/
@Override
public OutputStream writeResponseStatusAndHeaders(long contentLength, ContainerResponse responseContext) throws ContainerException {
jerseyResponse = responseContext;
HttpServerResponse response = vertxRequest.response();
// Write the status
response.setStatusCode(responseContext.getStatus());
response.setStatusMessage(responseContext.getStatusInfo().getReasonPhrase());
// Set the content length header
if (contentLength != -1) {
response.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(contentLength));
}
for (final Map.Entry<String, List<Object>> e : responseContext.getHeaders().entrySet()) {
for (final Object value : e.getValue()) {
response.putHeader(e.getKey(), String.valueOf(value));
}
}
// Run any response processors
if (!responseProcessors.isEmpty()) {
for (VertxResponseProcessor processor : responseProcessors) {
processor.process(response, responseContext);
}
}
// Return output stream based on whether entity is chunked
if (responseContext.isChunked()) {
response.setChunked(true);
return new VertxChunkedOutputStream(response);
} else {
return new VertxOutputStream(response);
}
}