class HttpServletResponseImpl implements HttpServletResponse {

    public void flushHeaders() throws IllegalStateException, IOException {
        if (isCommitted) {
            throw new IllegalStateException("Headers should not be committed more than once.");
        }

        isCommitted = true;

        for (Cookie cookie : cookies) {
            headers.setHeader(Headers.HEADER_SET_COOKIE, cookieHeaderSerializer.serialize(cookie));
        }

        byte[] head = (getStatus() + NEW_LINE + headersSerializer.serialize(headers))
                .getBytes(StandardCharsets.UTF_8);
        InputStream inputStream = new ByteArrayInputStream(head);
        serveStream(inputStream);

        IOUtilities.closeSilently(inputStream);
    }

    public  HttpServletResponseImpl(final Serializer<Headers> headersSerializer,
                                   final Serializer<Cookie> cookieHeaderSerializer,
                                   final StreamHelper streamHelper,
                                   final OutputStream outputStream);

}