52North/SOS — pull request #105 by shane-axiom (2014-08-16 04:23:19+00:00)
Title: Add ResponseProxy for response header access by ResponseWriters

A [previous commit](https://github.com/52North/SOS/commit/930573e3bbb47d2668383b9bddddee37ea53552c) I made tried to allow ResponseWriters to provide response headers and content length, but this didn't actually work correctly since all responses first use [AbstractServiceResponseWriter](https://github.com/52North/SOS/blob/develop/core/api/src/main/java/org/n52/sos/encode/AbstractServiceResponseWriter.java#L61) to enable streaming responses. AbstractServiceResponseWriter's headers and content length were being used instead of the underlying ResponseWriter.

This commit fixes that problem by creating a ResponseProxy object which wraps HttpServletResponse and provides access to only a few of its methods, currently .addHeader and .setContentLength. ResponseProxy is passed into the ResponseWriters to allow them to add response headers or set content length.

It would also be possible to manage the OutputStream being written to by the ResponseWriters inside the ResponseProxy, if desired. This would allow for centralized management of the OutputStream and methods like gZIpOutput(), isOutputGZipped(), etc. I didn't add this to keep the commit simple and unintrusive to the ResponseWriters and StreamingEncoders.