CB-6928: Open output stream only if it's necessary.
CB-6928: Handle 304 status code