* {@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<String>> e : responseContext.getStringHeaders().entrySet()) {
for (final String value : e.getValue()) {
response.putHeader(e.getKey(), 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 if (responseContext.hasEntity() && WriteStreamOutput.class.isAssignableFrom(responseContext.getEntityClass())) {
WriteStreamOutput writeStreamOutput = (WriteStreamOutput) responseContext.getEntity();
writeStreamOutput.init(response, event -> {
end();